修改交班数据
This commit is contained in:
@@ -51,7 +51,7 @@ public class MemberController {
|
||||
@RequestBody Map<String,Object> map
|
||||
|
||||
){
|
||||
return memberService.memberScanPay(map);
|
||||
return memberService.memberScanPay(map,token);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MemberController {
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam("flowId") String flowId
|
||||
){
|
||||
return memberService.queryScanPay(flowId);
|
||||
return memberService.queryScanPay(flowId,token);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MemberController {
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestBody Map<String,Object> map
|
||||
){
|
||||
return memberService.memberAccountPay(map);
|
||||
return memberService.memberAccountPay(map,token);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -73,9 +73,10 @@ public class PayController {
|
||||
@RequestHeader("loginName") String loginName,
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam("orderId") String orderId,
|
||||
@RequestParam("memberId") String memberId
|
||||
@RequestParam("memberId") String memberId,
|
||||
@RequestParam("memberAccount") String memberAccount
|
||||
){
|
||||
return payService.accountPay(orderId,memberId,token);
|
||||
return payService.accountPay(orderId,memberId,token,memberAccount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,4 +26,6 @@ public interface TbShopUserMapper {
|
||||
|
||||
|
||||
TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId);
|
||||
|
||||
TbShopUser selectByShopIdAndDdynamicCode(@Param("shopId") String shopId,@Param("memberAccount") String memberAccount);
|
||||
}
|
||||
@@ -42,6 +42,12 @@ public class ShopUserDuty implements Serializable {
|
||||
private String type;
|
||||
private List<ShopUserDutyDetail> detailList;
|
||||
|
||||
private BigDecimal memberInAmount;
|
||||
|
||||
private BigDecimal memberOutAmount;
|
||||
|
||||
private BigDecimal quickAmount;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ShopUserDuty() {
|
||||
|
||||
@@ -42,6 +42,8 @@ public class TbShopUser implements Serializable {
|
||||
|
||||
private String code;
|
||||
|
||||
private String dynamicCode;
|
||||
|
||||
private Byte isAttention;
|
||||
|
||||
private Integer attentionAt;
|
||||
@@ -285,4 +287,12 @@ public class TbShopUser implements Serializable {
|
||||
public void setMiniOpenId(String miniOpenId) {
|
||||
this.miniOpenId = miniOpenId == null ? null : miniOpenId.trim();
|
||||
}
|
||||
|
||||
public String getDynamicCode() {
|
||||
return dynamicCode;
|
||||
}
|
||||
|
||||
public void setDynamicCode(String dynamicCode) {
|
||||
this.dynamicCode = dynamicCode;
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,10 @@ public class HandoverInfo implements Serializable {
|
||||
|
||||
private String orderNum;
|
||||
|
||||
private String quickAmount;
|
||||
|
||||
public HandoverInfo(String merchantName, String startTime, String endTime, String staff, List<PayInfo> payInfos, List<HandoverInfo.MemberData> memberData, String totalAmount, String imprest, String payable, String handIn, String returnAmount,String orderNum
|
||||
,List<ProductCategory> productCategories
|
||||
,List<ProductCategory> productCategories,String quickAmount
|
||||
|
||||
) {
|
||||
this.merchantName = merchantName;
|
||||
@@ -53,6 +55,7 @@ public class HandoverInfo implements Serializable {
|
||||
this.returnAmount=returnAmount;
|
||||
this.orderNum = orderNum;
|
||||
this.productCategories=productCategories;
|
||||
this.quickAmount=quickAmount;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -618,7 +619,8 @@ public class CloudPrinterService {
|
||||
ShopUserDutyPay shopUserDutyPay=shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(),"deposit");
|
||||
if(ObjectUtil.isNotEmpty(shopUserDutyPay)){
|
||||
memberData=new ArrayList<>();
|
||||
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(),"储值卡支付"));
|
||||
memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"储值卡充值"));
|
||||
memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())? BigDecimal.ONE.toPlainString() : shopUserDuty.getMemberOutAmount().toPlainString(),"储值卡支付"));
|
||||
}
|
||||
|
||||
|
||||
@@ -632,13 +634,14 @@ public class CloudPrinterService {
|
||||
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null,
|
||||
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):"",
|
||||
ObjectUtil.isNull(shopStaff.getName())?"":shopStaff.getName(),
|
||||
list,memberData,shopUserDuty.getAmount().toPlainString(),
|
||||
list,memberData,shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).add(ObjectUtil.isNull(shopUserDuty.getIncomeAmount())?BigDecimal.ZERO:shopUserDuty.getIncomeAmount()).toPlainString(),
|
||||
"0",
|
||||
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
||||
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
||||
shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).add(ObjectUtil.isNull(shopUserDuty.getIncomeAmount())?BigDecimal.ZERO:shopUserDuty.getIncomeAmount()).subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
||||
shopUserDuty.getReturnAmount().toPlainString(),
|
||||
shopUserDuty.getOrderNum().toString(),
|
||||
productCategories
|
||||
productCategories,shopUserDuty.getQuickAmount().toPlainString()
|
||||
|
||||
);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
PrinterUtils.printTickets(voiceJson,1,1,it.getAddress(),PrinterUtils.handoverprintData(handoverInfo));
|
||||
|
||||
@@ -55,15 +55,12 @@ public class DutyService {
|
||||
System.out.println("数据落地开始:" + message);
|
||||
JSONObject jsonObject = JSON.parseObject(message);
|
||||
String token = jsonObject.getString("token");
|
||||
|
||||
String type = jsonObject.getString("type");
|
||||
boolean quick = jsonObject.containsKey("quick");
|
||||
TbToken tbToken = tbTokenMapper.selectByToken(token);
|
||||
String day = DateUtils.getDay();
|
||||
if (quick) {
|
||||
|
||||
|
||||
if ("quick".equals(type)) {
|
||||
Integer tokenId = tbToken.getId();
|
||||
String orderNo = jsonObject.getString("orderNo");
|
||||
BigDecimal amount = new BigDecimal(jsonObject.getString("amount"));
|
||||
|
||||
JSONObject tokenJson = TokenUtil.parseParamFromToken(tbToken.getToken());
|
||||
@@ -72,19 +69,45 @@ public class DutyService {
|
||||
String loginName = tokenJson.getString("loginName");
|
||||
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(shopId);
|
||||
ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0");
|
||||
|
||||
if (Objects.isNull(shopUserDuty)) {
|
||||
shopUserDuty = new ShopUserDuty(userId, tbToken.getCreateTime(), 1, amount, shopInfo.getShopName(), "0",
|
||||
amount, shopId, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "");
|
||||
if(Objects.isNull(shopUserDuty)){
|
||||
shopUserDuty = new ShopUserDuty(userId, tbToken.getCreateTime(), 1, BigDecimal.ZERO, shopInfo.getShopName(), "0",
|
||||
BigDecimal.ZERO, shopId, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "");
|
||||
shopUserDuty.setTokenId(tokenId);
|
||||
shopUserDuty.setReturnAmount(BigDecimal.ZERO);
|
||||
shopUserDuty.setTradeDay(DateUtils.getDay());
|
||||
shopUserDuty.setQuickAmount(amount);
|
||||
shopUserDutyMapper.insert(shopUserDuty);
|
||||
}else {
|
||||
shopUserDuty.setQuickAmount(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?amount:shopUserDuty.getQuickAmount().add(amount));
|
||||
shopUserDutyMapper.updateByPrimaryKey(shopUserDuty);
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if("memberIn".equals(type)){
|
||||
|
||||
Integer tokenId = tbToken.getId();
|
||||
BigDecimal amount = new BigDecimal(jsonObject.getString("amount"));
|
||||
|
||||
JSONObject tokenJson = TokenUtil.parseParamFromToken(tbToken.getToken());
|
||||
Integer shopId = tokenJson.getInteger("shopId");
|
||||
Integer userId = tokenJson.getInteger("staffId");
|
||||
String loginName = tokenJson.getString("loginName");
|
||||
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(shopId);
|
||||
ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0");
|
||||
if(Objects.isNull(shopUserDuty)){
|
||||
shopUserDuty = new ShopUserDuty(userId, tbToken.getCreateTime(), 1, BigDecimal.ZERO, shopInfo.getShopName(), "0",
|
||||
BigDecimal.ZERO, shopId, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "");
|
||||
shopUserDuty.setTokenId(tokenId);
|
||||
shopUserDuty.setReturnAmount(BigDecimal.ZERO);
|
||||
shopUserDuty.setTradeDay(DateUtils.getDay());
|
||||
shopUserDuty.setMemberInAmount(amount);
|
||||
shopUserDutyMapper.insert(shopUserDuty);
|
||||
}else {
|
||||
shopUserDuty.setMemberInAmount(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())?amount:shopUserDuty.getMemberInAmount().add(amount));
|
||||
shopUserDutyMapper.updateByPrimaryKey(shopUserDuty);
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
if (type.equals("return") || type.equals("create")) {
|
||||
if (Objects.isNull(tbToken)) {
|
||||
throw new MsgException("当前用户不存在");
|
||||
@@ -115,6 +138,7 @@ public class DutyService {
|
||||
shopUserDuty = new ShopUserDuty(userId, tbToken.getCreateTime(), 1, orderInfo.getOrderAmount(), shopInfo.getShopName(), "0",
|
||||
orderInfo.getOrderAmount(), shopId, BigDecimal.ZERO, cashAmount, BigDecimal.ZERO, "");
|
||||
shopUserDuty.setTokenId(tokenId);
|
||||
shopUserDuty.setMemberOutAmount("deposit".equals(orderInfo.getPayType())?orderInfo.getOrderAmount():BigDecimal.ZERO);
|
||||
shopUserDuty.setReturnAmount(BigDecimal.ZERO);
|
||||
shopUserDuty.setTradeDay(DateUtils.getDay());
|
||||
shopUserDutyMapper.insert(shopUserDuty);
|
||||
@@ -139,6 +163,7 @@ public class DutyService {
|
||||
shopUserDuty.setAmount(shopUserDuty.getAmount().add(orderInfo.getPayAmount()));
|
||||
shopUserDuty.setCashAmount(shopUserDuty.getCashAmount().add(cashAmount));
|
||||
shopUserDuty.setIncomeAmount(shopUserDuty.getIncomeAmount().add(orderInfo.getPayAmount()));
|
||||
shopUserDuty.setMemberOutAmount("deposit".equals(orderInfo.getPayType())?ObjectUtil.isNull(shopUserDuty.getMemberOutAmount())?orderInfo.getOrderAmount():shopUserDuty.getMemberOutAmount().add(orderInfo.getOrderAmount()):shopUserDuty.getMemberOutAmount());
|
||||
shopUserDuty.setOrderNum(shopUserDuty.getOrderNum() + 1);
|
||||
shopUserDutyMapper.updateByPrimaryKeySelective(shopUserDuty);
|
||||
List<Integer> skuIds = new ArrayList<>();
|
||||
@@ -313,7 +338,7 @@ public class DutyService {
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.getMessage();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
|
||||
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp;
|
||||
@@ -137,9 +138,11 @@ public class MemberService {
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
RabbitProducer producer;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result memberScanPay(Map<String, Object> map) {
|
||||
public Result memberScanPay(Map<String, Object> map,String token) {
|
||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0
|
||||
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|
||||
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|
||||
@@ -235,6 +238,17 @@ public class MemberService {
|
||||
flow.setBalance(shopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", token);
|
||||
jsonObject.put("type", "memberIn");
|
||||
jsonObject.put("amount", memberIn.getAmount());
|
||||
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, memberIn);
|
||||
} else {
|
||||
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
||||
@@ -304,11 +318,11 @@ public class MemberService {
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", token);
|
||||
jsonObject.put("type", "memberIn");
|
||||
jsonObject.put("amount",memberIn.getAmount());
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, memberIn);
|
||||
|
||||
@@ -333,7 +347,7 @@ public class MemberService {
|
||||
}
|
||||
|
||||
|
||||
public Result queryScanPay(String flowId) {
|
||||
public Result queryScanPay(String flowId,String token) {
|
||||
if (ObjectUtil.isEmpty(flowId)) {
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
@@ -440,6 +454,15 @@ public class MemberService {
|
||||
flow.setAmount(awardAmount);
|
||||
flow.setBalance(shopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", token);
|
||||
jsonObject.put("quick", "quick");
|
||||
jsonObject.put("consumeType","in");
|
||||
jsonObject.put("amount",memberIn.getAmount());
|
||||
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, memberIn);
|
||||
@@ -456,7 +479,7 @@ public class MemberService {
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result memberAccountPay(Map<String, Object> map) {
|
||||
public Result memberAccountPay(Map<String, Object> map,String token) {
|
||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0
|
||||
|| !map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))
|
||||
|| !map.containsKey("memberId") || ObjectUtil.isEmpty(map.get("memberId"))
|
||||
@@ -532,6 +555,13 @@ public class MemberService {
|
||||
flow.setBalance(shopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", token);
|
||||
jsonObject.put("type", "memberIn");
|
||||
jsonObject.put("amount",memberIn.getAmount());
|
||||
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -409,9 +409,20 @@ public class PayService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result accountPay(String orderId, String memberId, String token) {
|
||||
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberId)) {
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
public Result accountPay(String orderId, String memberId, String token,String memberAccount) {
|
||||
if (ObjectUtil.isEmpty(orderId) ) {
|
||||
if(ObjectUtil.isEmpty(memberAccount)){
|
||||
if(ObjectUtil.isEmpty(memberId)){
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
}
|
||||
|
||||
if(ObjectUtil.isEmpty(memberId)){
|
||||
if(ObjectUtil.isEmpty(memberAccount)){
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||
@@ -431,7 +442,18 @@ public class PayService {
|
||||
}
|
||||
|
||||
|
||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
|
||||
TbShopUser user =null;
|
||||
|
||||
if(ObjectUtil.isNotEmpty(memberId)){
|
||||
user =tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
|
||||
}
|
||||
|
||||
|
||||
if(ObjectUtil.isNotEmpty(memberAccount)){
|
||||
user=tbShopUserMapper.selectByShopIdAndDdynamicCode(orderInfo.getShopId(),memberAccount);
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
||||
return Result.fail(CodeEnum.MEMBERNOEXIST);
|
||||
}
|
||||
@@ -889,6 +911,14 @@ public class PayService {
|
||||
tbQuickPay.setStatus("0");
|
||||
tbQuickPay.setUpdateTime(new Date());
|
||||
tbQuickPayMapper.insert(tbQuickPay);
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", token);
|
||||
jsonObject.put("type", "quick");
|
||||
jsonObject.put("amount",tbQuickPay.getAmount());
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, tbQuickPay);
|
||||
|
||||
} else {
|
||||
@@ -940,8 +970,7 @@ public class PayService {
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", token);
|
||||
jsonObject.put("quick", "quick");
|
||||
jsonObject.put("orderNo",tbQuickPay.getOrderNo());
|
||||
jsonObject.put("type", "quick");
|
||||
jsonObject.put("amount",tbQuickPay.getAmount());
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
|
||||
@@ -185,6 +185,8 @@ public class PrinterUtils {
|
||||
sb.append("<S> "+productCategory.getCategoryName()+" "+ productCategory.getNum()+" "+productCategory.getAmount()+"</S><BR>");
|
||||
}
|
||||
}
|
||||
|
||||
sb.append("<S>快捷收款金额 :".concat(ObjectUtil.isNull(handoverInfo.getQuickAmount())?"0":handoverInfo.getQuickAmount())+"</S><BR>");
|
||||
sb.append("<S>退款金额 :".concat(handoverInfo.getReturnAmount())+"</S><BR>");
|
||||
sb.append("<S>总收入: "+handoverInfo.getTotalAmount()+"</S><BR>");
|
||||
sb.append("<S>备用金: "+handoverInfo.getImprest()+"</S><BR>");
|
||||
|
||||
Reference in New Issue
Block a user