|
|
@@ -27,6 +27,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.system.domain.*;
|
|
|
import com.ruoyi.system.domain.vo.OrderDTO;
|
|
|
@@ -107,6 +108,8 @@ public class PosOrderController extends BaseController {
|
|
|
private IPosOrderRatingService posOrderRatingService;
|
|
|
@Autowired
|
|
|
private IFoodStatisticsService foodStatisticsService;
|
|
|
+ @Autowired
|
|
|
+ private IOrderParentService orderParentService;
|
|
|
|
|
|
|
|
|
//查询用户足迹
|
|
|
@@ -908,12 +911,17 @@ public class PosOrderController extends BaseController {
|
|
|
queryWrapper.apply("NOT (state = 0 AND collect_payment = 0)");
|
|
|
IPage<PosOrder> list = posOrderService.page(palist, queryWrapper);
|
|
|
List<PosOrder> orlist = list.getRecords();
|
|
|
+List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect(Collectors.toList());
|
|
|
+ List<OrderParent> orderParents =new ArrayList<>();
|
|
|
+ if(!parentDdIds.isEmpty()){
|
|
|
+ orderParents= orderParentService.list(new LambdaQueryWrapper<>(OrderParent.class).in(OrderParent::getDdId, parentDdIds));
|
|
|
+ }
|
|
|
JSONArray arr = new JSONArray();
|
|
|
for (int i = 0; i < orlist.size(); i++) {
|
|
|
JSONObject org = new JSONObject();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
org.put("id", orlist.get(i).getId());
|
|
|
- org.put("ddId", orlist.get(i).getDdId());
|
|
|
+ org.put("ddId", orlist.get(i).getDdId().toString());
|
|
|
org.put("shanghu", infoUserService.getById(orlist.get(i).getShId()));
|
|
|
org.put("store", posStoreService.getById(orlist.get(i).getMdId()));
|
|
|
org.put("cretim", sdf.format(orlist.get(i).getCretim()));
|
|
|
@@ -951,6 +959,11 @@ public class PosOrderController extends BaseController {
|
|
|
org.put("pointsReduction", orlist.get(i).getPointsReduction());
|
|
|
org.put("sdTime", orlist.get(i).getSdTime());
|
|
|
org.put("payType", orlist.get(i).getPayType());
|
|
|
+ int finalI = i;
|
|
|
+ org.put("parentRemarks","");
|
|
|
+ if(StringUtils.isNotEmpty(orlist.get(i).getParentDdId())){
|
|
|
+ orderParents.stream().filter(item->item.getDdId().equals(orlist.get(finalI).getParentDdId())).findFirst().ifPresent(a-> org.put("parentRemarks",a.getRemarks()));
|
|
|
+ }
|
|
|
arr.add(org);
|
|
|
}
|
|
|
return success(arr);
|
|
|
@@ -1262,12 +1275,12 @@ public class PosOrderController extends BaseController {
|
|
|
walletQuery.eq(UserWallet::getUserId, userId);
|
|
|
UserWallet userWallet = userWalletService.getOne(walletQuery);
|
|
|
if (ObjectUtil.isNotNull(userWallet)) {
|
|
|
- if (userWallet.getPointsWallet().compareTo(Long.valueOf(orderDTO.getPoints())) >= 0) {
|
|
|
+ if (userWallet.getPointsWallet().compareTo(BigDecimal.valueOf(orderDTO.getPoints())) >= 0) {
|
|
|
walletQuery.eq(UserWallet::getVersion, userWallet.getVersion());
|
|
|
- userWallet.setPointsWallet(userWallet.getPointsWallet() - orderDTO.getPoints());
|
|
|
+ userWallet.setPointsWallet(userWallet.getPointsWallet().subtract(BigDecimal.valueOf(orderDTO.getPoints())));
|
|
|
userWallet.setVersion(userWallet.getVersion() + 1);
|
|
|
boolean update = userWalletService.update(userWallet, walletQuery);
|
|
|
- createPointTransaction(userId, Long.valueOf(orderDTO.getPoints()), userWallet.getPointsWallet(), orderDTO.getDdId(), "1");
|
|
|
+ createPointTransaction(userId, BigDecimal.valueOf(orderDTO.getPoints()), userWallet.getPointsWallet(), orderDTO.getDdId().toString(), "1");
|
|
|
if (!update) {
|
|
|
throw new ServiceException(MessageUtils.message("no.points.update.fail"));
|
|
|
}
|
|
|
@@ -1284,7 +1297,7 @@ public class PosOrderController extends BaseController {
|
|
|
/**
|
|
|
* 创建积分流水
|
|
|
*/
|
|
|
- private void createPointTransaction(Long userid, Long pointsChange, Long currentPoints, Long ddId, String type) {
|
|
|
+ private void createPointTransaction(Long userid, BigDecimal pointsChange, BigDecimal currentPoints, String ddId, String type) {
|
|
|
WalletTransaction pointsTransaction = new WalletTransaction();
|
|
|
pointsTransaction.setUserId(userid);
|
|
|
if (type.equals("1")) {
|
|
|
@@ -1307,7 +1320,7 @@ public class PosOrderController extends BaseController {
|
|
|
*
|
|
|
* @param orderId
|
|
|
*/
|
|
|
- private void redeemCoupons(VipUserQuanyi yh, VipUserQuanyi mdYh, Long orderId) {
|
|
|
+ private void redeemCoupons(VipUserQuanyi yh, VipUserQuanyi mdYh, String orderId) {
|
|
|
if (ObjectUtil.isNotNull(yh)) {
|
|
|
yh.setState("1");
|
|
|
yh.setOrderId(orderId);
|
|
|
@@ -1534,7 +1547,7 @@ public class PosOrderController extends BaseController {
|
|
|
}
|
|
|
//退款、作废退回积分
|
|
|
if ((posOrder.getState() == 7 || posOrder.getState() == 11) && posOrder.getPoints() != null && posOrder.getPoints() > 0) {
|
|
|
- returnPoints(posOrder.getUserId(), posOrder.getId(), Long.valueOf(posOrder.getPoints()));
|
|
|
+ returnPoints(posOrder.getUserId(), posOrder.getDdId(), Long.valueOf(posOrder.getPoints()));
|
|
|
}
|
|
|
return toAjax(posOrderService.updatePosOrder(posOrder));
|
|
|
} else {
|
|
|
@@ -1553,7 +1566,7 @@ public class PosOrderController extends BaseController {
|
|
|
* @param ddId
|
|
|
* @param points
|
|
|
*/
|
|
|
- public void returnPoints(Long userId, Long ddId, Long points) {
|
|
|
+ public void returnPoints(Long userId, String ddId, Long points) {
|
|
|
LambdaQueryWrapper<UserWallet> walletQuery = new LambdaQueryWrapper<>();
|
|
|
walletQuery.eq(UserWallet::getUserId, userId);
|
|
|
UserWallet userWallet = userWalletService.getOne(walletQuery);
|
|
|
@@ -1561,10 +1574,10 @@ public class PosOrderController extends BaseController {
|
|
|
//该订单不存在退回的积分记录
|
|
|
if (ObjectUtil.isNotNull(userWallet) && transaction == null) {
|
|
|
walletQuery.eq(UserWallet::getVersion, userWallet.getVersion());
|
|
|
- userWallet.setPointsWallet(userWallet.getPointsWallet() + points);
|
|
|
+ userWallet.setPointsWallet(userWallet.getPointsWallet().add(BigDecimal.valueOf(points)));
|
|
|
userWallet.setVersion(userWallet.getVersion() + 1);
|
|
|
boolean update = userWalletService.update(userWallet, walletQuery);
|
|
|
- createPointTransaction(userId, Long.valueOf(points), userWallet.getPointsWallet(), ddId, "2");
|
|
|
+ createPointTransaction(userId, BigDecimal.valueOf(points), userWallet.getPointsWallet(), ddId.toString(), "2");
|
|
|
if (!update) {
|
|
|
throw new ServiceException(MessageUtils.message("no.points.update.fail"));
|
|
|
}
|