Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
d827491c
Commit
d827491c
authored
Aug 20, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
c1a68c45
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
724 additions
and
0 deletions
+724
-0
BranchCompanyStockRight.java
...xxfc/platform/vehicle/entity/BranchCompanyStockRight.java
+74
-0
BranchCompanyStockInfoRightVo.java
...atform/vehicle/pojo/vo/BranchCompanyStockInfoRightVo.java
+24
-0
BranchCompanyStockRightBiz.java
...xxfc/platform/vehicle/biz/BranchCompanyStockRightBiz.java
+311
-0
BranchCompanyStockRightMapper.java
...latform/vehicle/mapper/BranchCompanyStockRightMapper.java
+16
-0
BranchCompanyStockRightController.java
...tform/vehicle/rest/BranchCompanyStockRightController.java
+233
-0
BranchCompanyStockRightMapper.xml
...c/main/resources/mapper/BranchCompanyStockRightMapper.xml
+66
-0
No files found.
xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/entity/BranchCompanyStockRight.java
0 → 100644
View file @
d827491c
package
com
.
xxfc
.
platform
.
vehicle
.
entity
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.math.BigDecimal
;
@Data
@Table
(
name
=
"branch_company_stock_info_right"
)
public
class
BranchCompanyStockRight
{
/**
* 分公司ID
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
,
generator
=
"JDBC"
)
private
Integer
id
;
/**
* 分公司id
*/
@Column
(
name
=
"company_id"
)
private
Integer
companyId
;
/**
* 剩余股份
*/
private
Integer
balance
;
/**
* 股份总数
*/
private
Integer
total
;
/**
* 股份单价
*/
private
BigDecimal
price
;
private
Integer
state
;
@Column
(
name
=
"company_pic"
)
private
String
companyPic
;
/**
* 详情
*/
private
String
info
;
/**
* 创建时间
*/
@Column
(
name
=
"crt_time"
)
private
Long
crtTime
;
/**
* 排序
*/
private
Integer
rank
;
/**
* 更新时间
*/
@Column
(
name
=
"upd_time"
)
private
Long
updTime
;
/**
* 是否删除:0-正常;1-删除
*/
@Column
(
name
=
"is_del"
)
private
Integer
isDel
;
}
\ No newline at end of file
xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/pojo/vo/BranchCompanyStockInfoRightVo.java
0 → 100644
View file @
d827491c
package
com
.
xxfc
.
platform
.
vehicle
.
pojo
.
vo
;
import
lombok.Data
;
import
java.math.BigDecimal
;
/**
* 分公司股份信息
*/
@Data
public
class
BranchCompanyStockInfoRightVo
{
Integer
id
;
Integer
companyId
;
String
companyName
;
Integer
balance
;
Integer
rank
;
Integer
total
;
BigDecimal
price
;
Integer
addrProvince
;
Integer
addrCity
;
Integer
state
;
String
companyPic
;
String
info
;
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/BranchCompanyStockRightBiz.java
0 → 100644
View file @
d827491c
package
com
.
xxfc
.
platform
.
vehicle
.
biz
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.vehicle.common.RestResponse
;
import
com.xxfc.platform.vehicle.constant.BranchCompanyStockApplyState
;
import
com.xxfc.platform.vehicle.constant.RedisKey
;
import
com.xxfc.platform.vehicle.constant.ResCode.ResCode
;
import
com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo
;
import
com.xxfc.platform.vehicle.entity.BranchCompanyStockInfo
;
import
com.xxfc.platform.vehicle.entity.BranchCompanyStockRight
;
import
com.xxfc.platform.vehicle.mapper.*
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyInfoVo
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyStockInfoVo
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo
;
import
com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo
;
import
com.xxfc.platform.vehicle.util.excel.ExcelImport
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.joda.time.DateTime
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormatter
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
tk.mybatis.mapper.entity.Example
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.File
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
@Service
public
class
BranchCompanyStockRightBiz
extends
BaseBiz
<
BranchCompanyStockRightMapper
,
BranchCompanyStockRight
>
{
public
static
final
DateTimeFormatter
DEFAULT_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
);
public
static
final
DateTimeFormatter
YEARMONTH_DATE_TIME_FORMATTER
=
DateTimeFormat
.
forPattern
(
"yyyy-MM"
);
@Value
(
"${branchCompanyStockPic.baseUploadPath:/data/branchCompanyStock/upload/}"
)
private
String
baseUploadPath
;
@Autowired
private
RedisTemplate
customRedisTemplate
;
@Autowired
BranchCompanyStockInfoMapper
branchCompanyStockInfoMapper
;
@Autowired
BranchCompanyMapper
branchCompanyMapper
;
@Autowired
BranchCompanyStockApplyInfoMapper
branchCompanyStockApplyInfoMapper
;
@Autowired
SysRegionMapper
sysRegionMapper
;
public
PageInfo
<
BranchCompanyStockInfoVo
>
selectAll
(
Integer
page
,
Integer
limit
)
{
PageHelper
.
startPage
(
page
,
limit
);
return
new
PageInfo
<>(
branchCompanyStockInfoMapper
.
selectVoAll
());
}
public
PageInfo
<
BranchCompanyStockInfoRightVo
>
search
(
BranchCompanyStockSearchVo
searchVo
)
{
PageHelper
.
startPage
(
searchVo
.
getPage
(),
searchVo
.
getLimit
());
return
new
PageInfo
<>(
mapper
.
search
(
searchVo
));
}
public
ObjectRestResponse
updStockInfo
(
BranchCompanyStockInfoRightVo
stockInfoVo
)
{
if
(
stockInfoVo
==
null
||
stockInfoVo
.
getCompanyId
()==
null
||
stockInfoVo
.
getCompanyId
()==
0
){
}
Integer
id
=
stockInfoVo
.
getId
();
if
(!
checkInfo
(
id
,
stockInfoVo
.
getCompanyId
())){
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"分公司已存在"
);
}
BranchCompanyStockRight
stockInfo
=
new
BranchCompanyStockRight
();
BeanUtils
.
copyProperties
(
stockInfoVo
,
stockInfo
);
if
(
stockInfo
.
getBalance
()
==
null
)
{
stockInfo
.
setBalance
(
stockInfo
.
getTotal
());
}
if
(
stockInfoVo
.
getState
()
==
null
)
{
stockInfo
.
setState
(
0
);
}
if
(
id
==
null
||
id
==
0
){
mapper
.
insertSelective
(
stockInfo
);
}
else
{
mapper
.
updateByPrimaryKeySelective
(
stockInfo
);
}
return
ObjectRestResponse
.
succ
();
}
/**
* 申请购买
* @param applyVo
*/
public
void
apply
(
BranchCompanyStockApplyVo
applyVo
)
{
BranchCompanyStockInfo
stockInfo
=
branchCompanyStockInfoMapper
.
selectByPrimaryKey
(
applyVo
.
getCompanyId
());
if
(
stockInfo
==
null
)
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_UNEXIST
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_UNEXIST
.
getCode
());
}
if
(
stockInfo
.
getBalance
()
<=
0
)
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_NO_BALANCE
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_NO_BALANCE
.
getCode
());
}
if
(
stockInfo
.
getBalance
()
<
applyVo
.
getCount
())
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH
.
getCode
());
}
BranchCompanyStockApplyInfo
applyInfo
=
new
BranchCompanyStockApplyInfo
();
BeanUtils
.
copyProperties
(
applyVo
,
applyInfo
);
applyInfo
.
setState
(
BranchCompanyStockApplyState
.
Apply
.
getCode
());
applyInfo
.
setCreateTime
(
new
Date
());
branchCompanyStockApplyInfoMapper
.
insertSelective
(
applyInfo
);
}
public
PageInfo
<
BranchCompanyStockApplyInfoVo
>
selectApplyAll
(
Integer
page
,
Integer
limit
)
{
PageHelper
.
startPage
(
page
,
limit
);
return
new
PageInfo
<>(
branchCompanyStockApplyInfoMapper
.
selectVoAll
());
}
/**
* 取消申请,修改申请状态
* @param applyId
*/
public
void
cancelApply
(
Integer
applyId
)
{
BranchCompanyStockApplyInfo
applyInfo
=
branchCompanyStockApplyInfoMapper
.
selectByPrimaryKey
(
applyId
);
if
(
applyInfo
==
null
)
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST
.
getCode
());
}
applyInfo
.
setState
(
BranchCompanyStockApplyState
.
Cancel
.
getCode
());
applyInfo
.
setUpdateTime
(
new
Date
());
branchCompanyStockApplyInfoMapper
.
updateByPrimaryKey
(
applyInfo
);
}
/**
* 确认申请购买股权,修改库存
* @param applyId
*/
@Transactional
public
void
buy
(
Integer
applyId
)
{
BranchCompanyStockApplyInfo
applyInfo
=
branchCompanyStockApplyInfoMapper
.
selectByPrimaryKey
(
applyId
);
if
(
applyInfo
==
null
)
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_APPLY_INFO_UNEXIST
.
getCode
());
}
if
(!
applyInfo
.
getState
().
equals
(
BranchCompanyStockApplyState
.
Apply
.
getCode
()))
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_APPLY_INFO_STATE_LOCKED
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_APPLY_INFO_STATE_LOCKED
.
getCode
());
}
BranchCompanyStockInfo
stockInfo
=
branchCompanyStockInfoMapper
.
selectByPrimaryKey
(
applyInfo
.
getCompanyId
());
if
(
stockInfo
==
null
)
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_UNEXIST
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_UNEXIST
.
getCode
());
}
if
(
stockInfo
.
getBalance
()
<
applyInfo
.
getCount
())
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH
.
getCode
());
}
int
result
=
branchCompanyStockInfoMapper
.
updateBalance
(
applyInfo
.
getCompanyId
(),
stockInfo
.
getBalance
()
-
applyInfo
.
getCount
(),
stockInfo
.
getBalance
());
if
(
result
==
0
)
{
throw
new
BaseException
(
ResCode
.
BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH
.
getDesc
(),
ResCode
.
BRANCH_COMPANY_STOCK_BALANCE_NOT_ENOUGH
.
getCode
());
}
applyInfo
.
setState
(
BranchCompanyStockApplyState
.
Buy
.
getCode
());
applyInfo
.
setUpdateTime
(
new
Date
());
branchCompanyStockApplyInfoMapper
.
updateByPrimaryKey
(
applyInfo
);
}
/**
* 获取所有的股权单价
* @return
*/
public
List
<
Integer
>
getAllPrice
()
{
return
branchCompanyStockInfoMapper
.
selectAllPrice
();
}
public
BranchCompanyStockInfo
selectById
(
Integer
id
)
{
return
branchCompanyStockInfoMapper
.
selectByPrimaryKey
(
id
);
}
public
void
delete
(
Integer
id
)
{
BranchCompanyStockRight
stockRight
=
new
BranchCompanyStockRight
();
stockRight
.
setId
(
id
);
stockRight
.
setIsDel
(
1
);
mapper
.
updateByPrimaryKeySelective
(
stockRight
);
}
public
BranchCompanyStockApplyInfo
getApplyById
(
Integer
id
)
{
return
branchCompanyStockApplyInfoMapper
.
selectByPrimaryKey
(
id
);
}
public
void
updateApply
(
BranchCompanyStockApplyInfo
applyInfo
)
{
branchCompanyStockApplyInfoMapper
.
updateByPrimaryKeySelective
(
applyInfo
);
}
public
void
deleteApply
(
Integer
id
)
{
branchCompanyStockApplyInfoMapper
.
deleteByPrimaryKey
(
id
);
}
/**
* 写入上传文件,返回相对路径
* @param file
* @return
*/
public
RestResponse
<
String
>
uploadCompanyPic
(
MultipartFile
file
)
throws
Exception
{
//创建本日存放目录
DateTime
now
=
DateTime
.
now
();
String
dirPathToday
=
File
.
separator
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
String
redisNoKey
=
RedisKey
.
UPLOAD_FILE_NO_PREFIX
+
now
.
toString
(
DEFAULT_DATE_TIME_FORMATTER
);
Long
no
=
customRedisTemplate
.
opsForValue
().
increment
(
redisNoKey
);
if
(
no
.
equals
(
1
l
)){
customRedisTemplate
.
expire
(
redisNoKey
,
1
,
TimeUnit
.
DAYS
);
}
String
fileName
=
file
.
getOriginalFilename
();
String
realFileRelPath
=
dirPathToday
+
File
.
separator
+
no
+
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
//文件存放路径
String
filePath
=
baseUploadPath
+
realFileRelPath
;
//将文件写入指定位置
FileUtils
.
copyInputStreamToFile
(
file
.
getInputStream
(),
new
File
(
filePath
));
return
RestResponse
.
suc
(
realFileRelPath
);
}
public
ResponseEntity
<
byte
[]>
downloadCompanyPic
(
String
realFileRelPath
)
throws
IOException
{
String
filePath
=
baseUploadPath
+
realFileRelPath
;
File
file
=
new
File
(
filePath
);
//新建一个文件
HttpHeaders
headers
=
new
HttpHeaders
();
//http头信息
String
downloadFileName
=
new
String
(
file
.
getName
());
//设置编码
headers
.
setContentDispositionFormData
(
"attachment"
,
downloadFileName
);
headers
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM
);
return
new
ResponseEntity
<
byte
[]>(
FileUtils
.
readFileToByteArray
(
file
),
headers
,
HttpStatus
.
CREATED
);
}
public
RestResponse
<
String
>
importExcel
(
MultipartFile
multipartfile
,
HttpServletRequest
request
){
try
{
List
<
String
[]>
readExcel
=
ExcelImport
.
getExcelData
(
multipartfile
);
if
(
readExcel
.
size
()<
4
){
return
RestResponse
.
codeAndMessage
(
1001
,
"导入不能没数据!!!"
);
}
List
<
BranchCompanyStockInfo
>
list
=
new
ArrayList
<>();
for
(
int
i
=
3
;
i
<
readExcel
.
size
();
i
++)
{
BranchCompanyStockInfo
stockInfoVo
=
new
BranchCompanyStockInfo
();
String
[]
str
=
readExcel
.
get
(
i
);
String
province
=
str
[
2
];
String
city
=
str
[
3
];
Integer
addr_province
=
sysRegionMapper
.
getNumber
(
province
);
Integer
addr_city
=
sysRegionMapper
.
getNumber
(
city
);
String
company_name
=
str
[
5
];
String
str6
=
str
[
6
];
if
(
StringUtils
.
isNotBlank
(
str6
)){
if
(
str6
.
contains
(
"万港币/股"
)){
str6
=
str6
.
replace
(
"万港币/股"
,
""
);
}
else
{
str6
=
str6
.
replace
(
"万/股"
,
""
);
}
}
else
{
str6
=
"0"
;
}
BigDecimal
price
=
new
BigDecimal
(
str6
);
price
=
price
.
multiply
(
new
BigDecimal
(
"10000"
));
Integer
balance
=
Integer
.
parseInt
(
str
[
8
]);
Integer
total
=
Integer
.
parseInt
(
str
[
7
])+
balance
;
stockInfoVo
.
setCompanyName
(
company_name
);
stockInfoVo
.
setPrice
(
price
);
stockInfoVo
.
setBalance
(
balance
);
stockInfoVo
.
setTotal
(
total
);
stockInfoVo
.
setState
(
2
);
stockInfoVo
.
setAddrProvince
(
addr_province
);
stockInfoVo
.
setAddrCity
(
addr_city
);
stockInfoVo
.
setCompanyPic
(
"/2019-04-30/2.jpg"
);
list
.
add
(
stockInfoVo
);
//branchCompanyStockInfoMapper.insertSelective(stockInfoVo);
}
branchCompanyStockInfoMapper
.
addCompamyList
(
list
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
return
RestResponse
.
codeAndMessage
(
10001
,
"网络异常!"
);
}
return
RestResponse
.
suc
();
}
public
boolean
checkInfo
(
Integer
id
,
Integer
companyId
)
{
Example
example
=
new
Example
(
BranchCompanyStockRight
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"companyId"
,
companyId
);
if
(
id
!=
null
&&
id
>
0
){
criteria
.
andNotEqualTo
(
"id"
,
id
);
}
List
<
BranchCompanyStockRight
>
list
=
mapper
.
selectByExample
(
example
);
if
(
list
.
size
()>
0
)
return
false
;
return
true
;
}
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/mapper/BranchCompanyStockRightMapper.java
0 → 100644
View file @
d827491c
package
com
.
xxfc
.
platform
.
vehicle
.
mapper
;
import
com.xxfc.platform.vehicle.entity.BranchCompanyStockRight
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo
;
import
com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
public
interface
BranchCompanyStockRightMapper
extends
Mapper
<
BranchCompanyStockRight
>
{
List
<
BranchCompanyStockInfoRightVo
>
search
(
BranchCompanyStockSearchVo
searchVo
);
}
\ No newline at end of file
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/rest/BranchCompanyStockRightController.java
0 → 100644
View file @
d827491c
package
com
.
xxfc
.
platform
.
vehicle
.
rest
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.vehicle.biz.BranchCompanyStockRightBiz
;
import
com.xxfc.platform.vehicle.biz.BranchCompanyStockService
;
import
com.xxfc.platform.vehicle.common.BaseController
;
import
com.xxfc.platform.vehicle.common.RestResponse
;
import
com.xxfc.platform.vehicle.constant.ResCode.ResCode
;
import
com.xxfc.platform.vehicle.entity.BranchCompanyStockApplyInfo
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyStockApplyVo
;
import
com.xxfc.platform.vehicle.pojo.BranchCompanyStockSearchVo
;
import
com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
@RestController
@IgnoreClientToken
@IgnoreUserToken
@RequestMapping
(
"branchCompany/stock/right"
)
public
class
BranchCompanyStockRightController
extends
BaseController
<
BranchCompanyStockRightBiz
>
{
private
static
Integer
MAX_DRIVING_LICENSE_SIZE
=
10
*
1024
*
1024
;
//10M
@Autowired
BranchCompanyStockService
branchCompanyStockService
;
/**
* 分页获取
* @param page
* @param limit
* @return
*/
@GetMapping
(
"page"
)
public
RestResponse
page
(
Integer
page
,
Integer
limit
)
{
if
(
page
==
null
||
limit
==
null
)
{
page
=
1
;
limit
=
10
;
}
return
RestResponse
.
suc
(
baseBiz
.
selectAll
(
page
,
limit
));
}
/**
* 搜索
* @param searchVo
* @return
*/
@GetMapping
(
"search"
)
public
RestResponse
search
(
BranchCompanyStockSearchVo
searchVo
)
{
if
(
searchVo
.
getPage
()
==
null
||
searchVo
.
getLimit
()
==
null
)
{
searchVo
.
setPage
(
1
);
searchVo
.
setLimit
(
10
);
}
return
RestResponse
.
suc
(
baseBiz
.
search
(
searchVo
));
}
@GetMapping
(
"{id}"
)
public
RestResponse
get
(
@PathVariable
(
"id"
)
Integer
id
)
{
if
(
id
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
return
RestResponse
.
suc
(
branchCompanyStockService
.
selectById
(
id
));
}
@GetMapping
(
"info/{id}"
)
public
RestResponse
getInfo
(
@PathVariable
(
"id"
)
Integer
id
)
{
if
(
id
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
return
RestResponse
.
suc
(
branchCompanyStockService
.
getInfoById
(
id
));
}
/**
* 更新
* @return
*/
@RequestMapping
(
value
=
"/updStockInfo"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
updStockInfo
(
@RequestBody
BranchCompanyStockInfoRightVo
stockInfoVo
)
{
if
(
stockInfoVo
==
null
||
stockInfoVo
.
getCompanyId
()==
null
||
stockInfoVo
.
getCompanyId
()==
0
||
stockInfoVo
.
getTotal
()
==
null
||
stockInfoVo
.
getPrice
()
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
NULL_CODE
,
"参数不能为空"
);
}
return
baseBiz
.
updStockInfo
(
stockInfoVo
);
}
/**
* 更新
* @return
*/
@RequestMapping
(
value
=
"/addStockInfo"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
addStockInfo
(
@RequestBody
BranchCompanyStockInfoRightVo
stockInfoVo
)
{
if
(
stockInfoVo
==
null
||
stockInfoVo
.
getCompanyId
()==
null
||
stockInfoVo
.
getCompanyId
()==
0
||
stockInfoVo
.
getTotal
()
==
null
||
stockInfoVo
.
getPrice
()
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
NULL_CODE
,
"参数不能为空"
);
}
return
baseBiz
.
updStockInfo
(
stockInfoVo
);
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping
(
"{id}"
)
public
ObjectRestResponse
delete
(
@PathVariable
(
"id"
)
Integer
id
)
{
baseBiz
.
delete
(
id
);
return
ObjectRestResponse
.
succ
();
}
@RequestMapping
(
value
=
"/upload/companyPic"
,
method
=
RequestMethod
.
POST
)
public
RestResponse
uploadCompanyPic
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
String
contentType
=
file
.
getContentType
();
//图片文件类型
if
(!
contentType
.
equals
(
"image/jpeg"
)
&&
!
contentType
.
equals
(
"image/gif"
)){
return
RestResponse
.
code
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
());
}
if
(
file
.
getSize
()
>
MAX_DRIVING_LICENSE_SIZE
){
return
RestResponse
.
code
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
());
}
return
branchCompanyStockService
.
uploadCompanyPic
(
file
);
}
@IgnoreUserToken
@RequestMapping
(
value
=
"/download/companyPic"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
byte
[]>
downloadDrivingLicense
(
@RequestParam
(
"realFileRelPath"
)
String
realFileRelPath
)
throws
Exception
{
return
branchCompanyStockService
.
downloadCompanyPic
(
realFileRelPath
);
}
/**
* 申请购买
* @param applyVo
* @return
*/
@PostMapping
(
"apply"
)
public
RestResponse
apply
(
@RequestBody
BranchCompanyStockApplyVo
applyVo
)
{
if
(
applyVo
.
getCompanyId
()
==
null
||
applyVo
.
getName
()
==
null
||
applyVo
.
getTel
()
==
null
||
applyVo
.
getCount
()
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
branchCompanyStockService
.
apply
(
applyVo
);
return
RestResponse
.
suc
();
}
@GetMapping
(
"apply/page"
)
public
RestResponse
applyPage
(
Integer
page
,
Integer
limit
)
{
if
(
page
==
null
||
limit
==
null
)
{
page
=
1
;
limit
=
10
;
}
return
RestResponse
.
suc
(
branchCompanyStockService
.
selectApplyAll
(
page
,
limit
));
}
@GetMapping
(
"apply/{id}"
)
public
RestResponse
getApplyById
(
@PathVariable
(
"id"
)
Integer
id
)
{
if
(
id
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
return
RestResponse
.
suc
(
branchCompanyStockService
.
getApplyById
(
id
));
}
@PutMapping
(
"apply"
)
public
RestResponse
updateApply
(
BranchCompanyStockApplyInfo
applyInfo
)
{
if
(
applyInfo
.
getId
()
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
branchCompanyStockService
.
updateApply
(
applyInfo
);
return
RestResponse
.
suc
();
}
@DeleteMapping
(
"apply/{id}"
)
public
RestResponse
deleteApply
(
@PathVariable
(
"id"
)
Integer
id
)
{
if
(
id
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
branchCompanyStockService
.
deleteApply
(
id
);
return
RestResponse
.
suc
();
}
/**
* 取消申请,放弃购买
* @return
*/
@PostMapping
(
"apply/cancel"
)
public
RestResponse
cancel
(
Integer
applyId
)
{
if
(
applyId
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
branchCompanyStockService
.
cancelApply
(
applyId
);
return
RestResponse
.
suc
();
}
/**
* 确认购买,减库存
*/
@PostMapping
(
"apply/buy"
)
public
RestResponse
buy
(
Integer
applyId
)
{
if
(
applyId
==
null
)
{
return
RestResponse
.
codeAndMessage
(
ResCode
.
INVALID_REST_REQ_PARAM
.
getCode
(),
ResCode
.
INVALID_REST_REQ_PARAM
.
getDesc
());
}
branchCompanyStockService
.
buy
(
applyId
);
return
RestResponse
.
suc
();
}
@GetMapping
(
"allPrice"
)
public
RestResponse
getAllPrice
()
{
return
RestResponse
.
suc
(
branchCompanyStockService
.
getAllPrice
());
}
/**
* 导入
* @param multipartfile
* @param request
* @return
*/
@PostMapping
(
"importExcel"
)
public
RestResponse
importExcel
(
@RequestParam
(
value
=
"file"
)
MultipartFile
multipartfile
,
HttpServletRequest
request
)
{
return
branchCompanyStockService
.
importExcel
(
multipartfile
,
request
);
}
}
xx-vehicle/xx-vehicle-server/src/main/resources/mapper/BranchCompanyStockRightMapper.xml
0 → 100644
View file @
d827491c
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.xxfc.platform.vehicle.mapper.BranchCompanyStockRightMapper"
>
<update
id=
"updateBalance"
>
update branch_company_stock_info
set balance = #{balance}
where id = #{companyId} and balance = #{lastBalance}
</update>
<select
id=
"selectVoAll"
resultType=
"com.xxfc.platform.vehicle.pojo.BranchCompanyStockInfoVo"
>
select *
from branch_company_stock_info
</select>
<select
id=
"search"
resultType=
"com.xxfc.platform.vehicle.pojo.vo.BranchCompanyStockInfoRightVo"
>
SELECT
distinct r.company_id as companyId,
r.id,
r.balance,
r.company_pic as companyPic,
r.info,
r.price,
r.rank,
r.total,
r.state,
c.addr_city AS addrCity,
c.addr_province AS addrProvince,
c.`name` AS companyName
FROM
branch_company_stock_info_right r
LEFT JOIN branch_company c ON r.company_id = c.id
<trim
prefix=
"where"
suffixOverrides=
"and"
>
c.is_del = 0
<if
test=
"companyName != null"
>
c.name like CONCAT('%',#{companyName},'%')
</if>
<if
test=
"addrProvince != null"
>
c.addr_province = #{addrProvince} and
</if>
<if
test=
"addrCity != null"
>
c.addr_city = #{addrCity} and
</if>
<if
test=
"priceStart"
>
r.price >= #{priceStart} and
</if>
<if
test=
"priceEnd"
>
r.price
<
= #{priceEnd} and
</if>
</trim>
order by rank desc
</select>
<select
id=
"selectAllPrice"
resultType=
"int"
>
select distinct price from branch_company_stock_info order by price
</select>
<select
id=
"selectInfoById"
resultType=
"String"
>
select info from branch_company_stock_info where id = #{id}
</select>
<insert
id=
"addCompamyList"
parameterType=
"java.util.List"
>
insert into branch_company_stock_info (
balance,total,price,company_name,addr_province,addr_city,state,company_pic
) VALUES
<foreach
collection =
"list"
item=
"item"
index=
"index"
separator =
","
>
(#{item.balance},#{item.total},#{item.price},#{item.companyName},#{item.addrProvince},#{item.addrCity},#{item.state},#{item.companyPic})
</foreach>
</insert>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment