修改交班数据

This commit is contained in:
韩鹏辉 2024-05-29 16:00:12 +08:00
parent 664e57e145
commit 9482cf4597
14 changed files with 172 additions and 41 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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() {

View File

@ -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;
}
}

View File

@ -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

View File

@ -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));

View File

@ -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();
}
}

View File

@ -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());
}

View File

@ -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());

View File

@ -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>");

View File

@ -17,7 +17,7 @@ spring:
com.chaozhanggui.system.openness: info
redis:
# redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突
database: 1
database: 0
# redis服务器地址默认为localhost
host: 101.37.12.135
# redis端口默认为6379

View File

@ -20,10 +20,14 @@
<result column="equipment" jdbcType="VARCHAR" property="equipment"/>
<result column="trade_day" jdbcType="VARCHAR" property="tradeDay"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="member_in_amount" jdbcType="DECIMAL" property="memberInAmount"/>
<result column="member_out_amount" jdbcType="DECIMAL" property="memberOutAmount"/>
<result column="quick_amount" jdbcType="DECIMAL" property="quickAmount"/>
</resultMap>
<sql id="Base_Column_List">
id, user_id, login_time, order_num, amount, login_out_time, user_name, status, income_amount,
shop_id, petty_cash, cash_amount, hand_amount, equipment,return_amount,token_id,trade_day,type
shop_id, petty_cash, cash_amount, hand_amount, equipment,return_amount,token_id,trade_day,type,member_in_amount,member_out_amount,quick_amount
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@ -58,12 +62,15 @@
order_num, amount, login_out_time,
user_name, status, income_amount,
shop_id, petty_cash, cash_amount,
hand_amount, equipment,return_amount,token_id,trade_day,type)
hand_amount, equipment,return_amount,token_id,trade_day,type,member_in_amount,member_out_amount,quick_amount)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{loginTime,jdbcType=TIMESTAMP},
#{orderNum,jdbcType=INTEGER}, #{amount,jdbcType=VARCHAR}, #{loginOutTime,jdbcType=TIMESTAMP},
#{userName,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{incomeAmount,jdbcType=DECIMAL},
#{shopId,jdbcType=INTEGER}, #{pettyCash,jdbcType=DECIMAL}, #{cashAmount,jdbcType=DECIMAL},
#{handAmount,jdbcType=DECIMAL}, #{equipment,jdbcType=VARCHAR}, #{returnAmount,jdbcType=DECIMAL},#{tokenId,jdbcType=INTEGER},#{tradeDay,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR})
#{handAmount,jdbcType=DECIMAL}, #{equipment,jdbcType=VARCHAR}, #{returnAmount,jdbcType=DECIMAL},#{tokenId,jdbcType=INTEGER},#{tradeDay,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR}
,#{memberInAmount,jdbcType=DECIMAL},#{memberOutAmount,jdbcType=DECIMAL},#{quickAmount,jdbcType=DECIMAL}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
insert into tb_shop_user_duty
@ -201,6 +208,10 @@
<if test="returnAmount != null">
return_amount = #{returnAmount,jdbcType=DECIMAL},
</if>
<if test="memberOutAmount != null">
member_out_amount = #{memberOutAmount,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
@ -218,7 +229,10 @@
petty_cash = #{pettyCash,jdbcType=DECIMAL},
cash_amount = #{cashAmount,jdbcType=DECIMAL},
hand_amount = #{handAmount,jdbcType=DECIMAL},
equipment = #{equipment,jdbcType=VARCHAR}
equipment = #{equipment,jdbcType=VARCHAR},
member_in_amount=#{memberInAmount,jdbcType=DECIMAL}
,member_out_amount=#{memberOutAmount,jdbcType=DECIMAL},
quick_amount=#{quickAmount,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatusByTokenId">

View File

@ -21,6 +21,8 @@
<result column="telephone" jdbcType="VARCHAR" property="telephone" />
<result column="is_vip" jdbcType="TINYINT" property="isVip" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="dynamic_code" jdbcType="VARCHAR" property="dynamicCode" />
<result column="is_attention" jdbcType="TINYINT" property="isAttention" />
<result column="attention_at" jdbcType="INTEGER" property="attentionAt" />
<result column="is_shareholder" jdbcType="TINYINT" property="isShareholder" />
@ -35,7 +37,7 @@
id, amount, credit_amount, consume_amount, consume_number, level_consume, status,
merchant_id, shop_id, user_id, parent_id, parent_level, name, head_img, sex, birth_day,
telephone, is_vip, code, is_attention, attention_at, is_shareholder, level, distribute_type,
sort, created_at, updated_at, mini_open_id
sort, created_at, updated_at, mini_open_id,dynamic_code
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@ -377,4 +379,8 @@
<select id="selectByUserIdAndShopId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId} and shop_id =#{shopId}
</select>
<select id="selectByShopIdAndDdynamicCode" resultMap="BaseResultMap">
select * from tb_shop_user where shop_id=#{shopId} and dynamic_code=#{memberAccount}
</select>
</mapper>