Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
Overview
Overview
Details
Activity
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
hooloo
ms
soss
Commits
3020ccff
Commit
3020ccff
authored
Sep 16, 2022
by
caiyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整订单取单号逻辑及微信支付逻辑
parent
7d5256bc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
131 deletions
+68
-131
soss-admin/src/main/java/com/soss/web/controller/coffee/MachineApiController.java
+1
-1
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
+24
-2
soss-system/src/main/java/com/soss/system/domain/Order.java
+5
-0
soss-system/src/main/java/com/soss/system/domain/vo/orderTaking/GoodsVo.java
+14
-122
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
+18
-6
soss-system/src/main/java/com/soss/system/service/impl/OrderTakingServiceImpl.java
+1
-0
soss-system/src/main/resources/mapper/system/OrderMapper.xml
+5
-0
No files found.
soss-admin/src/main/java/com/soss/web/controller/coffee/MachineApiController.java
View file @
3020ccff
...
...
@@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"/
test
"
)
@RequestMapping
(
"/
v1
"
)
@Slf4j
public
class
MachineApiController
{
@Autowired
...
...
soss-admin/src/main/java/com/soss/web/controller/coffee/OrderController.java
View file @
3020ccff
package
com
.
soss
.
web
.
controller
.
coffee
;
import
com.alibaba.fastjson.JSONObject
;
import
com.soss.common.annotation.Log
;
import
com.soss.common.constant.HttpStatus
;
import
com.soss.common.core.controller.BaseController
;
...
...
@@ -10,6 +11,7 @@ import com.soss.common.enums.BusinessType;
import
com.soss.common.exception.ServiceException
;
import
com.soss.framework.web.service.TokenService
;
import
com.soss.framework.web.service.WeixinServiceImpl
;
import
com.soss.system.constants.OrderStatusConstant
;
import
com.soss.system.domain.Order
;
import
com.soss.system.domain.vo.CouponVo
;
import
com.soss.system.domain.vo.OrderQuery
;
...
...
@@ -19,6 +21,7 @@ import com.soss.system.service.impl.OrderServiceImpl;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -27,6 +30,7 @@ import javax.servlet.http.HttpServletRequest;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* 订单Controller
...
...
@@ -145,6 +149,8 @@ public class OrderController extends BaseController {
Map
payInfo
=
weixinService
.
pay
(
request
,
"hooloo"
,
order
.
getOrderNo
(),
order
.
getUserId
(),
amount
);
if
(
payInfo
!=
null
)
{
payInfo
.
put
(
"orderId"
,
order
.
getId
());
order
.
setPayParam
(
JSONObject
.
toJSONString
(
payInfo
));
orderService
.
updateById
(
order
);
return
AjaxResult
.
success
(
payInfo
);
}
else
{
throw
new
ServiceException
(
"微信支付发生异常"
);
...
...
@@ -154,8 +160,14 @@ public class OrderController extends BaseController {
@RequestMapping
(
"/payOrder"
)
public
AjaxResult
cancel
(
HttpServletRequest
request
,
Long
orderId
)
{
Order
order
=
orderService
.
selectOrderById
(
orderId
);
order
.
setOrderNo
(
orderService
.
getOrderNo
(
order
.
getSource
()));
orderService
.
updateOrder
(
order
);
Assert
.
notNull
(
order
,
"order not exists"
);
Assert
.
isTrue
(
Objects
.
equals
(
order
.
getState
(),
OrderStatusConstant
.
Unpaid
),
"订单当前状态不支持该操作"
);
if
(
StringUtils
.
hasText
(
order
.
getPayParam
()))
{
return
AjaxResult
.
success
(
JSONObject
.
parseObject
(
order
.
getPayParam
()));
}
// order.setOrderNo(orderService.getOrderNo(order.getSource()));
// orderService.updateOrder(order);
int
amount
=
order
.
getPaidAmount
().
movePointRight
(
2
).
intValue
();
if
(
amount
==
0
)
{
return
AjaxResult
.
success
();
...
...
@@ -182,4 +194,14 @@ public class OrderController extends BaseController {
public
AjaxResult
cancel
(
Long
orderId
)
{
return
toAjax
(
orderService
.
cancel
(
orderId
));
}
@GetMapping
(
"/init/{id}"
)
public
AjaxResult
initPickCode
(
@PathVariable
Long
id
)
{
Order
order
=
orderService
.
selectById
(
id
);
Assert
.
notNull
(
order
,
"order not exists"
);
String
pickCode
=
weixinService
.
generatePickCode
(
order
);
order
.
setPickCode
(
pickCode
);
orderService
.
updateById
(
order
);
return
AjaxResult
.
success
();
}
}
soss-system/src/main/java/com/soss/system/domain/Order.java
View file @
3020ccff
...
...
@@ -146,6 +146,11 @@ public class Order implements Serializable {
private
Boolean
sendMsgFlag3
;
/**
* 支付参数
*/
private
String
payParam
;
/**
* 创建时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
soss-system/src/main/java/com/soss/system/domain/vo/orderTaking/GoodsVo.java
View file @
3020ccff
...
...
@@ -2,139 +2,31 @@ package com.soss.system.domain.vo.orderTaking;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
GoodsVo
{
private
String
goodsId
;
private
String
name
;
private
String
price
;
public
List
<
SkuVo
>
getSkus
()
{
return
skus
;
}
public
void
setSkus
(
List
<
SkuVo
>
skus
)
{
this
.
skus
=
skus
;
}
private
String
goodsId
;
private
String
name
;
private
String
price
;
private
List
<
SkuVo
>
skus
;
public
String
getGoodsId
()
{
return
goodsId
;
}
public
void
setGoodsId
(
String
goodsId
)
{
this
.
goodsId
=
goodsId
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getPrice
()
{
return
price
;
}
public
void
setPrice
(
String
price
)
{
this
.
price
=
price
;
}
public
String
getDiscount
()
{
return
discount
;
}
public
void
setDiscount
(
String
discount
)
{
this
.
discount
=
discount
;
}
public
String
getDesc
()
{
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
public
String
getRemarks
()
{
return
remarks
;
}
public
void
setRemarks
(
String
remarks
)
{
this
.
remarks
=
remarks
;
}
public
List
<
String
>
getTags
()
{
return
tags
;
}
public
void
setTags
(
List
<
String
>
tags
)
{
this
.
tags
=
tags
;
}
private
String
discount
;
private
String
pictures
;
private
JSONObject
pics
;
public
String
getPictures
()
{
return
pictures
;
}
public
void
setPictures
(
String
pictures
)
{
this
.
pictures
=
pictures
;
}
public
JSONArray
getSpecs
()
{
return
specs
;
}
public
void
setSpecs
(
JSONArray
specs
)
{
this
.
specs
=
specs
;
}
public
JSONObject
getPics
()
{
return
pics
;
}
public
String
getSpecString
()
{
return
specString
;
}
public
void
setSpecString
(
String
specString
)
{
this
.
specString
=
specString
;
}
public
void
setPics
(
JSONObject
pics
)
{
this
.
pics
=
pics
;
}
private
String
discount
;
private
String
pictures
;
private
JSONObject
pics
;
private
String
desc
;
private
String
remarks
;
public
String
getIsRecommend
()
{
return
isRecommend
;
}
public
void
setIsRecommend
(
String
isRecommend
)
{
this
.
isRecommend
=
isRecommend
;
}
private
String
remarks
;
private
List
<
String
>
tags
;
private
JSONArray
specs
;
private
JSONArray
specs
;
private
String
specString
;
private
String
specString
;
private
String
isRecommend
;
private
String
isRecommend
;
private
String
category
;
}
soss-system/src/main/java/com/soss/system/service/impl/OrderServiceImpl.java
View file @
3020ccff
...
...
@@ -107,6 +107,10 @@ public class OrderServiceImpl implements IOrderService {
return
orderMapper
.
selectOrderById
(
id
);
}
public
void
updateById
(
Order
order
)
{
orderMapper
.
updateOrder
(
order
);
}
/**
* 查询订单列表
*
...
...
@@ -474,21 +478,22 @@ public class OrderServiceImpl implements IOrderService {
Calendar
calendar
=
Calendar
.
getInstance
();
String
key
=
calendar
.
getTime
().
toString
().
substring
(
0
,
3
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
format
=
simpleDateFormat
.
format
(
new
Dat
e
());
String
format
=
simpleDateFormat
.
format
(
calendar
.
getTim
e
());
String
redisKey
=
"shopId"
+
format
+
shopId
;
RedisAtomicInteger
redisAtomicInteger
=
new
RedisAtomicInteger
(
redisKey
,
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
).
getConnectionFactory
());
if
(
redisAtomicInteger
.
get
()
==
0
)
{
redisAtomicInteger
.
set
((
int
)
(
1000
*
Math
.
random
()
));
redisAtomicInteger
.
set
((
int
)
(
998
*
Math
.
random
()
+
1
));
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
expireTime
=
DateUtils
.
addDaysAndGetBegin
(
now
,
1
);
long
seconds
=
Duration
.
between
(
now
,
expireTime
).
getSeconds
();
redisAtomicInteger
.
expire
(
seconds
,
TimeUnit
.
SECONDS
);
}
int
orderNum
=
redisAtomicInteger
.
addAndGet
(
3
);
if
(
orderNum
%
999
==
0
)
{
orderNum
=
redisAtomicInteger
.
addAndGet
(
1
);
int
delta
=
(
int
)
(
Math
.
random
()
*
8
+
1
);
int
orderNum
=
redisAtomicInteger
.
addAndGet
(
delta
);
if
(
orderNum
>
999
)
{
redisAtomicInteger
.
set
(
1
);
orderNum
=
1
;
}
orderNum
%=
999
;
return
key
+
String
.
format
(
"%03d"
,
orderNum
);
}
...
...
@@ -642,6 +647,7 @@ public class OrderServiceImpl implements IOrderService {
List
<
CategoryVo
>
categorys
=
infoByShop
.
getCategorys
();
List
<
GoodsVo
>
ccs
=
new
ArrayList
<>();
if
(
categorys
!=
null
&&
!
categorys
.
isEmpty
())
{
Set
<
String
>
cateAndGoodsIdSet
=
new
HashSet
<>();
for
(
CategoryVo
category
:
categorys
)
{
if
(
category
.
getId
()
==
0
)
{
continue
;
...
...
@@ -651,6 +657,12 @@ public class OrderServiceImpl implements IOrderService {
continue
;
}
for
(
GoodsVo
good
:
goods
)
{
String
cateAndGoodsIdStr
=
good
.
getCategory
()
+
good
.
getGoodsId
();
if
(
cateAndGoodsIdSet
.
contains
(
cateAndGoodsIdStr
))
{
continue
;
}
else
{
cateAndGoodsIdSet
.
add
(
cateAndGoodsIdStr
);
}
List
<
SkuVo
>
skuVoList
=
new
ArrayList
<>();
if
(
good
.
getSkus
()
==
null
||
good
.
getSkus
().
isEmpty
())
{
continue
;
...
...
soss-system/src/main/java/com/soss/system/service/impl/OrderTakingServiceImpl.java
View file @
3020ccff
...
...
@@ -174,6 +174,7 @@ public class OrderTakingServiceImpl {
goodsVo
.
setPics
(
JSONObject
.
parseObject
(
good
.
getPics
()));
goodsVo
.
setRemarks
(
good
.
getRemarks
());
goodsVo
.
setSpecs
(
buildGoodsSpec
(
good
.
getSpec
()));
goodsVo
.
setCategory
(
good
.
getCategory
());
goodsVo
.
setSpecString
(
null
);
if
(
recommendGoodsId
.
contains
(
String
.
valueOf
(
good
.
getId
()))){
goodsVo
.
setIsRecommend
(
"1"
);
...
...
soss-system/src/main/resources/mapper/system/OrderMapper.xml
View file @
3020ccff
...
...
@@ -28,6 +28,7 @@
<result
property=
"sendMsgFlag1"
column=
"send_msg_flag1"
/>
<result
property=
"sendMsgFlag2"
column=
"send_msg_flag2"
/>
<result
property=
"sendMsgFlag3"
column=
"send_msg_flag3"
/>
<result
property=
"payParam"
column=
"pay_param"
/>
<result
property=
"createdAt"
column=
"created_at"
/>
<result
property=
"updatedAt"
column=
"updated_at"
/>
</resultMap>
...
...
@@ -61,6 +62,7 @@
<if
test=
"sendMsgFlag1 != null"
>
and send_msg_flag1 = #{sendMsgFlag1}
</if>
<if
test=
"sendMsgFlag2 != null"
>
and send_msg_flag2 = #{sendMsgFlag2}
</if>
<if
test=
"sendMsgFlag3 != null"
>
and send_msg_flag3 = #{sendMsgFlag3}
</if>
<if
test=
"payParam != null"
>
and pay_param = #{payParam}
</if>
<if
test=
"createdAt != null "
>
and created_at = #{createdAt}
</if>
<if
test=
"updatedAt != null "
>
and updated_at = #{updatedAt}
</if>
...
...
@@ -97,6 +99,7 @@
<if
test=
"sendMsgFlag1 != null"
>
send_msg_flag1,
</if>
<if
test=
"sendMsgFlag2 != null"
>
send_msg_flag2,
</if>
<if
test=
"sendMsgFlag3 != null"
>
send_msg_flag3,
</if>
<if
test=
"payParam != null"
>
pay_param,
</if>
<if
test=
"createdAt != null"
>
created_at,
</if>
<if
test=
"updatedAt != null"
>
updated_at,
</if>
</trim>
...
...
@@ -123,6 +126,7 @@
<if
test=
"sendMsgFlag1 != null"
>
#{sendMsgFlag1},
</if>
<if
test=
"sendMsgFlag2 != null"
>
#{sendMsgFlag2},
</if>
<if
test=
"sendMsgFlag3 != null"
>
#{sendMsgFlag3},
</if>
<if
test=
"payParam != null"
>
#{pay_param},
</if>
<if
test=
"createdAt != null"
>
#{createdAt},
</if>
<if
test=
"updatedAt != null"
>
#{updatedAt},
</if>
</trim>
...
...
@@ -153,6 +157,7 @@
<if
test=
"sendMsgFlag1 != null"
>
send_msg_flag1 = #{sendMsgFlag1},
</if>
<if
test=
"sendMsgFlag2 != null"
>
send_msg_flag2 = #{sendMsgFlag2},
</if>
<if
test=
"sendMsgFlag3 != null"
>
send_msg_flag3 = #{sendMsgFlag3},
</if>
<if
test=
"payParam != null"
>
pay_param = #{payParam},
</if>
<if
test=
"updatedAt != null"
>
updated_at = #{updatedAt},
</if>
</trim>
where id = #{id}
...
...
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