修改打印数据
This commit is contained in:
@@ -77,6 +77,29 @@ public class PayController {
|
|||||||
return payService.accountPay(orderId,memberId,token);
|
return payService.accountPay(orderId,memberId,token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员扫码支付
|
||||||
|
* @param token
|
||||||
|
* @param loginName
|
||||||
|
* @param clientType
|
||||||
|
* @param orderId
|
||||||
|
* @param memberCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("memberScanPay")
|
||||||
|
public Result memberScanPay(@RequestHeader("token") String token,
|
||||||
|
@RequestHeader("loginName") String loginName,
|
||||||
|
@RequestHeader("clientType") String clientType,
|
||||||
|
@RequestParam("orderId") String orderId,
|
||||||
|
@RequestParam("memberCode") String memberCode
|
||||||
|
){
|
||||||
|
return payService.memberScanPay(orderId,memberCode,token);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 现金支付
|
* 现金支付
|
||||||
* @param token
|
* @param token
|
||||||
|
|||||||
@@ -28,4 +28,7 @@ public interface ShopUserDutyPayMapper {
|
|||||||
|
|
||||||
|
|
||||||
List<Map<String,Object>> selectByDutyId(Integer dutyId);
|
List<Map<String,Object>> selectByDutyId(Integer dutyId);
|
||||||
|
|
||||||
|
|
||||||
|
List<Map<String,Object>> selectCetoryBydutyId(Integer dutyId);
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.dao;
|
package com.chaozhanggui.system.cashierservice.dao;
|
||||||
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
|
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Mapper
|
||||||
public interface TbUserInfoMapper {
|
public interface TbUserInfoMapper {
|
||||||
int deleteByPrimaryKey(Integer id);
|
int deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
@@ -14,4 +18,6 @@ public interface TbUserInfoMapper {
|
|||||||
int updateByPrimaryKeySelective(TbUserInfo record);
|
int updateByPrimaryKeySelective(TbUserInfo record);
|
||||||
|
|
||||||
int updateByPrimaryKey(TbUserInfo record);
|
int updateByPrimaryKey(TbUserInfo record);
|
||||||
|
|
||||||
|
TbUserInfo selectByCardNo(String cardNo);
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,8 @@ public class HandoverInfo implements Serializable {
|
|||||||
|
|
||||||
private List<MemberData> memberData;
|
private List<MemberData> memberData;
|
||||||
|
|
||||||
|
private List<ProductCategory> productCategories;
|
||||||
|
|
||||||
private String totalAmount;
|
private String totalAmount;
|
||||||
|
|
||||||
|
|
||||||
@@ -34,7 +36,10 @@ public class HandoverInfo implements Serializable {
|
|||||||
|
|
||||||
private String orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
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) {
|
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
|
||||||
|
|
||||||
|
) {
|
||||||
this.merchantName = merchantName;
|
this.merchantName = merchantName;
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
@@ -47,6 +52,7 @@ public class HandoverInfo implements Serializable {
|
|||||||
this.handIn = handIn;
|
this.handIn = handIn;
|
||||||
this.returnAmount=returnAmount;
|
this.returnAmount=returnAmount;
|
||||||
this.orderNum = orderNum;
|
this.orderNum = orderNum;
|
||||||
|
this.productCategories=productCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -72,4 +78,19 @@ public class HandoverInfo implements Serializable {
|
|||||||
this.deposit = deposit;
|
this.deposit = deposit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ProductCategory{
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
private String num;
|
||||||
|
|
||||||
|
private String amount;
|
||||||
|
|
||||||
|
public ProductCategory(String categoryName, String num, String amount) {
|
||||||
|
this.categoryName = categoryName;
|
||||||
|
this.num = num;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -569,6 +569,7 @@ public class CloudPrinterService {
|
|||||||
|
|
||||||
List<HandoverInfo.PayInfo> list=null;
|
List<HandoverInfo.PayInfo> list=null;
|
||||||
List<HandoverInfo.MemberData> memberData=null;
|
List<HandoverInfo.MemberData> memberData=null;
|
||||||
|
List<HandoverInfo.ProductCategory> productCategories=null;
|
||||||
List<Map<String,Object>> mapList= shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId());
|
List<Map<String,Object>> mapList= shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId());
|
||||||
if(ObjectUtil.isNotEmpty(mapList)&&mapList.size()>0){
|
if(ObjectUtil.isNotEmpty(mapList)&&mapList.size()>0){
|
||||||
list= JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class);
|
list= JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class);
|
||||||
@@ -580,6 +581,13 @@ public class CloudPrinterService {
|
|||||||
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(),"储值卡支付"));
|
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(),"储值卡支付"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<Map<String,Object>> categries= shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId());
|
||||||
|
if(ObjectUtil.isNotEmpty(categries)&&categries.size()>0){
|
||||||
|
productCategories=JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries),HandoverInfo.ProductCategory.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(),
|
HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(),
|
||||||
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null,
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null,
|
||||||
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):"",
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):"",
|
||||||
@@ -589,7 +597,8 @@ public class CloudPrinterService {
|
|||||||
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
||||||
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
||||||
shopUserDuty.getReturnAmount().toPlainString(),
|
shopUserDuty.getReturnAmount().toPlainString(),
|
||||||
shopUserDuty.getOrderNum().toString()
|
shopUserDuty.getOrderNum().toString(),
|
||||||
|
productCategories
|
||||||
);
|
);
|
||||||
|
|
||||||
PrinterUtils.printTickets(1,1,it.getAddress(),PrinterUtils.handoverprintData(handoverInfo));
|
PrinterUtils.printTickets(1,1,it.getAddress(),PrinterUtils.handoverprintData(handoverInfo));
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ public class PayService {
|
|||||||
RabbitProducer producer;
|
RabbitProducer producer;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbUserInfoMapper tbUserInfoMapper;
|
||||||
|
|
||||||
|
|
||||||
@Value("${gateway.url}")
|
@Value("${gateway.url}")
|
||||||
private String gateWayUrl;
|
private String gateWayUrl;
|
||||||
|
|
||||||
@@ -310,6 +314,7 @@ public class PayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
|
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(Integer.valueOf(memberId));
|
||||||
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
||||||
return Result.fail(CodeEnum.MEMBERNOEXIST);
|
return Result.fail(CodeEnum.MEMBERNOEXIST);
|
||||||
@@ -365,6 +370,91 @@ public class PayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result memberScanPay(String orderId, String memberCode, String token) {
|
||||||
|
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberCode)) {
|
||||||
|
return Result.fail(CodeEnum.PARAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||||
|
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||||
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||||
|
return Result.fail(CodeEnum.ORDERSTATUSERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "deposit");
|
||||||
|
if (count < 1) {
|
||||||
|
return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbUserInfo tbUserInfo=tbUserInfoMapper.selectByCardNo(memberCode);
|
||||||
|
if(ObjectUtil.isEmpty(tbUserInfo)){
|
||||||
|
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbShopUser user = tbShopUserMapper.selectByShopId(orderInfo.getShopId(),tbUserInfo.getId().toString()).get(0);
|
||||||
|
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
||||||
|
return Result.fail(CodeEnum.MEMBERNOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (N.gt(orderInfo.getPayAmount(), user.getAmount())) {
|
||||||
|
return Result.fail(CodeEnum.MEMBERINSUFFICIENTFUNDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
|
||||||
|
user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount()));
|
||||||
|
user.setConsumeNumber(user.getConsumeNumber() + 1);
|
||||||
|
user.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbShopUserMapper.updateByPrimaryKeySelective(user);
|
||||||
|
|
||||||
|
|
||||||
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
|
flow.setShopUserId(user.getId());
|
||||||
|
flow.setBizCode("accountPay");
|
||||||
|
flow.setBizName("会员储值卡支付");
|
||||||
|
flow.setAmount(orderInfo.getOrderAmount());
|
||||||
|
flow.setBalance(user.getAmount());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbShopUserFlowMapper.insert(flow);
|
||||||
|
|
||||||
|
|
||||||
|
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||||
|
orderInfo.setMemberId(user.getUserId().toString());
|
||||||
|
orderInfo.setPayType("deposit");
|
||||||
|
orderInfo.setStatus("closed");
|
||||||
|
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||||
|
//更新购物车状态
|
||||||
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
||||||
|
|
||||||
|
|
||||||
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed");
|
||||||
|
|
||||||
|
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
|
||||||
|
|
||||||
|
log.info("更新购物车:{}", cartCount);
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("token", token);
|
||||||
|
jsonObject.put("type", "create");
|
||||||
|
jsonObject.put("orderId", orderId);
|
||||||
|
|
||||||
|
producer.putOrderCollect(jsonObject.toJSONString());
|
||||||
|
|
||||||
|
producer.printMechine(orderId);
|
||||||
|
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result cashPay(String orderId, String token) {
|
public Result cashPay(String orderId, String token) {
|
||||||
if (ObjectUtil.isEmpty(orderId)) {
|
if (ObjectUtil.isEmpty(orderId)) {
|
||||||
|
|||||||
@@ -173,6 +173,13 @@ public class PrinterUtils {
|
|||||||
sb.append("<S> "+memberDatum.getDeposit()+": "+memberDatum.getAmount()+"</S><BR>");
|
sb.append("<S> "+memberDatum.getDeposit()+": "+memberDatum.getAmount()+"</S><BR>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ObjectUtil.isNotEmpty(handoverInfo.getProductCategories())&&handoverInfo.getProductCategories().size()>0){
|
||||||
|
sb.append("<S>分类数据</S><BR>");
|
||||||
|
for(HandoverInfo.ProductCategory productCategory:handoverInfo.getProductCategories()){
|
||||||
|
sb.append("<S> "+productCategory.getCategoryName()+" "+ productCategory.getNum()+" "+productCategory.getAmount()+"</S><BR>");
|
||||||
|
}
|
||||||
|
}
|
||||||
sb.append("<S>退款金额 :".concat(handoverInfo.getReturnAmount())+"</S><BR>");
|
sb.append("<S>退款金额 :".concat(handoverInfo.getReturnAmount())+"</S><BR>");
|
||||||
sb.append("<S>总收入: "+handoverInfo.getTotalAmount()+"</S><BR>");
|
sb.append("<S>总收入: "+handoverInfo.getTotalAmount()+"</S><BR>");
|
||||||
sb.append("<S>备用金: "+handoverInfo.getImprest()+"</S><BR>");
|
sb.append("<S>备用金: "+handoverInfo.getImprest()+"</S><BR>");
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
server:
|
||||||
|
port: 10587
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://rm-bp1b572nblln4jho2po.mysql.rds.aliyuncs.com/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false
|
url: jdbc:mysql://rm-bp1b572nblln4jho2po.mysql.rds.aliyuncs.com/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false
|
||||||
@@ -13,9 +15,9 @@ spring:
|
|||||||
com.chaozhanggui.system.openness: info
|
com.chaozhanggui.system.openness: info
|
||||||
redis:
|
redis:
|
||||||
# redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突
|
# redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突
|
||||||
database: 5
|
database: 0
|
||||||
# redis服务器地址(默认为localhost)
|
# redis服务器地址(默认为localhost)
|
||||||
host: 101.37.12.135
|
host: 121.40.128.145
|
||||||
# redis端口(默认为6379)
|
# redis端口(默认为6379)
|
||||||
port: 6379
|
port: 6379
|
||||||
# redis访问密码(默认为空)
|
# redis访问密码(默认为空)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ spring:
|
|||||||
server:
|
server:
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /cashier-client/
|
context-path: /cashier-client/
|
||||||
port: 10587
|
|
||||||
# 日志配置
|
# 日志配置
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|||||||
@@ -100,4 +100,22 @@
|
|||||||
WHERE
|
WHERE
|
||||||
duty_id = #{dutyId}
|
duty_id = #{dutyId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCetoryBydutyId" resultType="java.util.Map">
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
sum( d.amount ) AS amount,
|
||||||
|
sum( d.num ) AS num,
|
||||||
|
c.`name` AS categoryName
|
||||||
|
FROM
|
||||||
|
tb_shop_user_duty_detail d
|
||||||
|
LEFT JOIN tb_product p ON d.product_id = p.id
|
||||||
|
LEFT JOIN tb_shop_category c ON p.category_id = c.id
|
||||||
|
WHERE
|
||||||
|
d.duty_id = #{dutyId}
|
||||||
|
GROUP BY
|
||||||
|
p.category_id
|
||||||
|
ORDER BY
|
||||||
|
c.sort DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -564,4 +564,8 @@
|
|||||||
grand_parent_id = #{grandParentId,jdbcType=VARCHAR}
|
grand_parent_id = #{grandParentId,jdbcType=VARCHAR}
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectByCardNo" resultMap="BaseResultMap">
|
||||||
|
select * from tb_user_info where card_no=#{cardNo}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user