diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java index 0dea7e961..03990cce7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/controller/FyPayController.java @@ -140,26 +140,26 @@ public class FyPayController { String orderLock = "orderLock_notify"+orderNo; if (redisLock.tryLock(orderLock,5000, TimeUnit.MILLISECONDS)){ // 业务逻辑 判断订单状态 -// AllOrderInfo allOrderInfo = allOrderInfoService.selectAllOrderInfoByOrderNo(orderNo); -// if (ObjectUtil.isNotEmpty(allOrderInfo)){ -// allOrderInfo.setPayMoney(Double.valueOf(settleOrderAmt)/100); -// allOrderInfo.setTransactionId(transactionId); -// allOrderInfo.setStatus("paid"); -// allOrderInfo.setPayTime(new Date()); -// allOrderInfoService.updateAllOrderInfo(allOrderInfo); -// -// // 修改配置收款账户余额信息 -// MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(allOrderInfo.getStoreId()); -// Double beforeAmount = merchantConfig.getAmount(); -// Double afterAmount = beforeAmount + allOrderInfo.getPayMoney(); -// merchantConfig.setAmount(afterAmount); -// merchantConfigService.updateMerch(merchantConfig); -// merchantConfigRecordService.updateMerchantConfigRecordByOrderNo(orderNo,"yes"); -// } -// -// updateOrderStatus(orderNo,allOrderInfo.getType()); -//// 修改订单支付状态 -// redisLock.unlock(orderLock); + AllOrderInfo allOrderInfo = allOrderInfoService.selectAllOrderInfoByOrderNo(orderNo); + if (ObjectUtil.isNotEmpty(allOrderInfo)){ + allOrderInfo.setPayMoney(Double.valueOf(settleOrderAmt)/100); + allOrderInfo.setTransactionId(transactionId); + allOrderInfo.setStatus("paid"); + allOrderInfo.setPayTime(new Date()); + allOrderInfoService.updateAllOrderInfo(allOrderInfo); + + // 修改配置收款账户余额信息 + MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(allOrderInfo.getStoreId()); + Double beforeAmount = merchantConfig.getAmount(); + Double afterAmount = beforeAmount + allOrderInfo.getPayMoney(); + merchantConfig.setAmount(afterAmount); + merchantConfigService.updateMerch(merchantConfig); + merchantConfigRecordService.updateMerchantConfigRecordByOrderNo(orderNo,"yes"); + } + + updateOrderStatus(orderNo,allOrderInfo.getType()); +// 修改订单支付状态 + redisLock.unlock(orderLock); } // transaction_id 加锁 return "1"; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java index c7ffc92c4..956fba457 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/entity/Const.java @@ -50,8 +50,8 @@ public class Const { //小程序异步通知(回调地址) // public static String notify_url = "https://www.tuofeng.cc/oilAdmin/api/fyPay/notify"; - public static String notify_url = "http://k40180f897.goho.co/api/fyPay/notify"; -// public static String notify_url = "https://8q4f124343.yicp.fun/api/fyPay/notify"; +// public static String notify_url = "http://k40180f897.goho.co/api/fyPay/notify"; + public static String notify_url = "https://8q4f124343.yicp.fun/api/fyPay/notify"; //主扫异步通知(回调地址) // public static String notify_url_scan = "https://www.tuofeng.cc/oilAdmin/api/fyPay/notifyScan"; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java index e4737a78b..404acf702 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java @@ -839,6 +839,7 @@ public class FyPayServiceImpl implements FyPayService { map.put("random_str", "orderNo"); map.put("order_type", receiveParameterPos.getPayType()); map.put("goods_des", receiveParameterPos.getContent()); + map.put("goods_detail", receiveParameterPos.getContent()); double amount = receiveParameterPos.getGoodsMoney() * 100; map.put("order_amt", String.valueOf((int) amount)); String nowtime = DateUtil.format(new Date(), "yyyyMMddHHmmss"); @@ -849,6 +850,18 @@ public class FyPayServiceImpl implements FyPayService { Const.INS_PUBLIC_KEY = publicKey; Const.INS_PRIVATE_KEY = privateKey; + if (ObjectUtil.isNotEmpty(merchantConfig)) { + +// 添加配置记录信息 + MerchantConfigRecord merchantConfigRecord = new MerchantConfigRecord(); + merchantConfigRecord.setMerchantId(merchantConfig.getId()); + merchantConfigRecord.setIsSuccess("no"); + merchantConfigRecord.setAmount(receiveParameterPos.getGoodsMoney()); + merchantConfigRecord.setType("0"); + merchantConfigRecord.setStoreId(merchantConfig.getStoreId()); + merchantConfigRecord.setOrderNo(receiveParameterPos.getOrderNo()); + merchantConfigRecordService.insertMerchantConfigRecord(merchantConfigRecord); + } // 请求报文 String reqBody = Message.requestMsg(map); // 响应报文 @@ -859,6 +872,13 @@ public class FyPayServiceImpl implements FyPayService { String str = resMap.get("sign"); if (Utils.verifySign(resMap, str)) { + OilOrder oilOrder = oilOrderService.selectOilOrderByOrderNo(receiveParameterPos.getOrderNo()); + ReceiveParameter receiveParameter = new ReceiveParameter(); + BeanUtils.copyProperties(receiveParameterPos, receiveParameter); +// 添加订单信息 + Double discountAmount = 0.0; + if (ObjectUtil.isNotEmpty(oilOrder)) discountAmount = oilOrder.getDiscountAmount(); + this.insertAllOrderInfo(receiveParameter, discountAmount); System.out.println(resMap); } return resMap; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java index e47a04ecf..bc035309f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java @@ -211,6 +211,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { cardFuelRecordDTO.setStoreId(nowAccountInfo.getStoreId()); cardFuelRecordDTO.setChainStoreId(nowAccountInfo.getChainStoreId()); cardFuelRecordDTO.setPayAmount(cardFuelRecordDTO.getRechargeBalance()); + cardFuelRecordDTO.setMtStaffId(nowAccountInfo.getStaffId()); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/HandoverRecordController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/HandoverRecordController.java index 796cdffe5..3409281fa 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/HandoverRecordController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/HandoverRecordController.java @@ -81,6 +81,13 @@ public class HandoverRecordController extends BaseController { return getSuccessResult(this.handoverRecordService.insert(handoverRecord)); } + @PostMapping("addByPos") + public ResponseObject addByPos(@RequestBody HandoverRecord handoverRecord) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + handoverRecord.setStaffId(nowAccountInfo.getStaffId()); + return getSuccessResult(this.handoverRecordService.insert(handoverRecord)); + } + /** * 编辑数据 * diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java index e6c32d533..3e923c8cc 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java @@ -342,4 +342,14 @@ public class OilOrderController extends BaseController { public ResponseObject addOrderPos(@RequestBody OilOrderVo oilOrderVo) throws Exception { return getSuccessResult(orderService.addOrderPos(oilOrderVo)); } + + /** + * pos端扫码支付 + * @param oilOrderVo + * @return + */ + @PostMapping("addOrderScanPos") + public ResponseObject addOrderScanPos(@RequestBody OilOrderVo oilOrderVo) throws Exception { + return getSuccessResult(orderService.addOrderPosScan(oilOrderVo)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HandoverRecord.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HandoverRecord.java index e7dccae09..6a26e25c5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HandoverRecord.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HandoverRecord.java @@ -28,6 +28,7 @@ public class HandoverRecord extends BaseEntity { * 交班数据记录 */ private String recordData; + @TableField(exist = false) private String totalPayMoney; private String staffName; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/AllOrderInfoMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/AllOrderInfoMapper.xml index a5a1aeb30..a7ccd772a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/AllOrderInfoMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/AllOrderInfoMapper.xml @@ -319,7 +319,16 @@ SUM(CASE WHEN aoi.content = '储值卡订单' THEN pay_money ELSE 0 END) AS userBalance, COUNT(CASE WHEN aoi.content = '储值卡订单' THEN 0 END) AS userBalanceCount, SUM(CASE WHEN aoi.content = '油品充值' THEN pay_money ELSE 0 END) AS oilBalance, - COUNT(CASE WHEN aoi.content = '油品充值' THEN 0 END) AS oilBalanceCount + COUNT(CASE WHEN aoi.content = '油品充值' THEN 0 END) AS oilBalanceCount, + + SUM(CASE WHEN aoi.content = '储值卡订单' and pay_type = 'WECHAT' THEN pay_money ELSE 0 END) AS userBalanceByWechat, + COUNT(CASE WHEN aoi.content = '储值卡订单' and pay_type = 'WECHAT' THEN 0 END) AS userBalanceCountByWechat, + SUM(CASE WHEN aoi.content = '储值卡订单' and pay_type = 'ALIPAY' THEN pay_money ELSE 0 END) AS userBalanceByAli, + COUNT(CASE WHEN aoi.content = '储值卡订单' and pay_type = 'ALIPAY' THEN 0 END) AS userBalanceCountByali + + + + from all_order_info aoi left join mt_user mu ON aoi.user_id = mu.id @@ -376,21 +385,29 @@ all_order_info staff_id = #{staffId} - - AND start_time >= #{startTime} -- 开始时间检索 - - - AND end_time <= #{endTime} -- 结束时间检索 - + + and date_format(pay_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d') + + + and date_format(pay_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d') + - - + + - - + + + + + + + + + + \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java index e9dc2bb71..a0539531b 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java @@ -222,5 +222,5 @@ public interface OilOrderService extends IService { * @param oilOrderVo * @return */ - Map addOrderPosScan(OilOrderVo oilOrderVo) throws Exception; + Map addOrderPosScan(OilOrderVo oilOrderVo) throws Exception; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java index 3ba032ef2..efeced973 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java @@ -100,6 +100,11 @@ public class AllOrderInfoServiceImpl extends ServiceImpl longs = new ArrayList<>(); + longs.add(l); + allOrderInfo.setStoreIds(longs); +// AllOrderInfoVo tradingData = allOrderInfoMapper.getTradingData(allOrderInfo); return allOrderInfoMapper.getTradingData(allOrderInfo); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java index ae9573b39..055bc4010 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java @@ -11,6 +11,7 @@ import com.fuint.business.order.mapper.AllOrderInfoMapper; import com.fuint.business.order.mapper.HandoverRecordMapper; import com.fuint.business.order.service.AllOrderInfoService; import com.fuint.business.order.service.HandoverRecordService; +import com.fuint.business.order.vo.AllOrderInfoVo; import com.fuint.business.store.entity.MtStore; import com.fuint.business.store.service.StoreService; import com.fuint.business.userManager.mapper.LJUserMapper; @@ -83,14 +84,14 @@ public class HandoverRecordServiceImpl implements HandoverRecordService { for (HandoverRecord record : handoverRecordIPage.getRecords()) { - DateTime dateTime = DateTime.of(record.getStartTime()); - DateTime dateTime1 = DateTime.of(record.getEndTime()); - record.setEndTime1(dateTime.toString()); - record.setStartTime1(dateTime1.toString()); - allOrderInfoMapper.getHandOverList(record); - record.setTotalPayMoney(record.getTotalPayMoney()); +// DateTime dateTime = DateTime.of(record.getStartTime()); +// DateTime dateTime1 = DateTime.of(record.getEndTime()); +// record.setEndTime1(dateTime.toString()); +// record.setStartTime1(dateTime1.toString()); + AllOrderInfoVo handOverList = allOrderInfoMapper.getHandOverList(record); + record.setTotalPayMoney(handOverList.getTotalPayMoney()); } - return this.handoverRecordMapper.queryAllByLimit(page, handoverRecord); + return handoverRecordIPage; } @Override diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java index 12430e5b7..3fd0c4820 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java @@ -1727,7 +1727,8 @@ public class OilOrderServiceImpl extends ServiceImpl i int row = 0; OilOrder oilOrder = this.selectOilOrderByOrderNo(orderNo); Integer userId = oilOrder.getUserId(); - LJUser user = userService.queryUserByUserId(userId); + LJUser user = null; + if (ObjectUtil.isNotEmpty(userId)) user = userService.queryUserByUserId(userId); if (ObjectUtil.isNotEmpty(oilOrder)) { // oilOrder.setPayAmount(oilOrder.getOrderAmount()-oilOrder.getDiscountAmount()); oilOrder.setOrderStatus(status); @@ -1781,14 +1782,16 @@ public class OilOrderServiceImpl extends ServiceImpl i cardValueChildOrder.setPayTime(new Date()); cardValueChildOrderService.updateCardValueChildOrder(cardValueChildOrder); + if (ObjectUtil.isNotEmpty(user)) { // 查询主卡信息 - CardValudChildrens cardValudChildrens = cardValudChildrensService.selectCardValueChildrenByMobileAndStoreId(user.getMobile(), oilOrder.getStoreId()); - userId = cardValudChildrens.getUserId(); + CardValudChildrens cardValudChildrens = cardValudChildrensService.selectCardValueChildrenByMobileAndStoreId(user.getMobile(), oilOrder.getStoreId()); + userId = cardValudChildrens.getUserId(); + } } - this.updateGrowthValue(oilOrder.getOrderAmount(), oilOrder.getPayAmount(), userId, Integer.valueOf(oilOrder.getOils()), null, oilOrder.getStoreId(), orderNo); + if (ObjectUtil.isNotEmpty(userId)) this.updateGrowthValue(oilOrder.getOrderAmount(), oilOrder.getPayAmount(), userId, Integer.valueOf(oilOrder.getOils()), null, oilOrder.getStoreId(), orderNo); this.addOilTracks(oilOrder, oilOrder.getStoreId()); this.updateCardAndActiveById(oilOrder.getStoreId(), oilOrder.getUserId(), oilOrder.getActiveId(), oilOrder.getCouponId(), oilOrder.getActiveType(), oilOrder.getOrderAmount(), oilOrder.getPayAmount(), Integer.valueOf(oilOrder.getOils())); - this.insertCardBalance(oilOrder.getOrderAmount() - oilOrder.getDiscountAmount() - oilOrder.getPayAmount(), userId, oilOrder.getStoreId(), orderNo); + if (ObjectUtil.isNotEmpty(userId)) this.insertCardBalance(oilOrder.getOrderAmount() - oilOrder.getDiscountAmount() - oilOrder.getPayAmount(), userId, oilOrder.getStoreId(), orderNo); if (ObjectUtil.isNotEmpty(oilOrder.getStaffId())) staffCommissionService.countStaffCommission(oilOrder.getStaffId(), oilOrder.getStoreId(), oilOrder.getOrderAmount(), oilOrder.getPayAmount(), "1", orderNo); } @@ -2385,7 +2388,7 @@ public class OilOrderServiceImpl extends ServiceImpl i this.addOilTracks(oilOrderVo, nowAccountInfo.getStoreId()); this.updateCardAndActiveById(nowAccountInfo.getStoreId(), oilOrderVo.getUserId(), oilOrderVo.getActiveId(), oilOrderVo.getCouponId(), oilOrderVo.getActiveType(), oilOrderVo.getOrderAmount(), oilOrderVo.getPayAmount(), Integer.valueOf(oilOrderVo.getOils())); this.insertAllOrderInfo(orderNo, nowAccountInfo.getStoreId(), oilOrderVo.getOrderAmount(), oilOrderVo.getPayAmount(), oilOrderVo.getDiscountAmount(), oilOrderVo.getPayType(), oilOrderVo.getUserId(), "POS", "1", "paid"); - this.insertFavorable(oilOrderVo, oilOrderVo.getOilCardAmount()); + this.insertFavorable(oilOrderVo, oilOrderVo.getOilCardAmount1()); if (ObjectUtil.isNotEmpty(oilOrderVo.getUserId())) integralSettingsService.refuelPoints(oilOrderVo); //修改优惠券使用状态 if (oilOrderVo.getCouponId() != null) { @@ -2406,8 +2409,8 @@ public class OilOrderServiceImpl extends ServiceImpl i } @Override - public Map addOrderPosScan(OilOrderVo oilOrderVo) throws Exception { - Map res = new HashMap<>(); + public Map addOrderPosScan(OilOrderVo oilOrderVo) throws Exception { + Map res = new HashMap<>(); AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); // 根据日期生成订单信息 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); @@ -2415,23 +2418,34 @@ public class OilOrderServiceImpl extends ServiceImpl i String randomString = UUID.randomUUID().toString().replace("-", "").substring(0, 6); String orderNo = "2345" + timestamp + randomString; - oilOrderVo.setOrderNo(orderNo); oilOrderVo.setStoreId(nowAccountInfo.getStoreId()); oilOrderVo.setStaffId(nowAccountInfo.getStaffId()); oilOrderVo.setTerminal("POS"); oilOrderVo.setOrderStatus("unpaid"); oilOrderVo.setOrderType("主订单"); - int row = baseMapper.insert(oilOrderVo); + if (ObjectUtil.isNotEmpty(oilOrderVo.getOrderNo())){ + OilOrder oilOrder = this.selectOilOrderByOrderNo(oilOrderVo.getOrderNo()); + oilOrderVo.setId(oilOrder.getId()); + oilOrderVo.setOrderNo(orderNo); + baseMapper.updateById(oilOrderVo); + }else { + oilOrderVo.setOrderNo(orderNo); + baseMapper.insert(oilOrderVo); + } + ReceiveParameterPos receiveParameterPos = new ReceiveParameterPos(); +// receiveParameterPos.setPayType("WECHAT"); receiveParameterPos.setPayType(oilOrderVo.getPayType()); receiveParameterPos.setType("1"); receiveParameterPos.setContent("油品订单"); receiveParameterPos.setOrderNo(orderNo); receiveParameterPos.setStoreId(oilOrderVo.getStoreId()); - receiveParameterPos.setStoreId(oilOrderVo.getUserId()); + receiveParameterPos.setUserId(oilOrderVo.getUserId()); receiveParameterPos.setGoodsMoney(oilOrderVo.getPayAmount()); receiveParameterPos.setOilCardAmount(oilOrderVo.getOilCardAmount1()); Map mainScan = fyPayService.mainScan(receiveParameterPos); - return mainScan; + res.put("oilOrder",this.selectOilOrderByOrderNo(orderNo)); + res.put("scanCode",mainScan); + return res; } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/AllOrderInfoVo.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/AllOrderInfoVo.java index 00dbc84d1..db47b8ef9 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/AllOrderInfoVo.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/AllOrderInfoVo.java @@ -24,6 +24,7 @@ public class AllOrderInfoVo extends AllOrderInfo { private String strokesPerDay; private String storeCount ; private String inertiaStore; + private String avatar; @@ -55,6 +56,11 @@ public class AllOrderInfoVo extends AllOrderInfo { private String totalCount; private String totalRefund; + private String userBalanceByWechat; + private String userBalanceCountByWechat; + private String userBalanceByAli; + private String userBalanceCountByali; + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/controller/printerController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/controller/printerController.java new file mode 100644 index 000000000..a09180137 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/controller/printerController.java @@ -0,0 +1,319 @@ +package com.fuint.business.printer.controller; + + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.internal.util.codec.Base64; +import com.fuint.business.printer.entity.Test; +import com.fuint.business.printer.service.PrinterService; +import com.fuint.business.printer.template.*; +import com.fuint.business.printer.unit.Methods; +import com.fuint.business.printer.vo.OrderPayment; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.Constants; +import com.fuint.common.util.RedisUtil; +import com.fuint.common.util.TokenUtil; +import com.fuint.framework.web.BaseController; +import com.fuint.framework.web.ResponseObject; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +//import com.yly.print_sdk_librar.RequestMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.cache.CacheProperties; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +import javax.annotation.Resource; +import javax.crypto.Cipher; +import javax.crypto.spec.GCMParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.Signature; +import java.security.spec.X509EncodedKeySpec; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/business/printer") +//@EnableWebMvc +@Slf4j +public class printerController extends BaseController { + + @Resource + PrinterService printerService; + + @GetMapping("callback") + public Map callback(Map map){ + log.info("------print/callback-------"); + Map objectObjectHashMap = new HashMap<>(); + objectObjectHashMap.put("message","ok"); + return objectObjectHashMap; + } + + @GetMapping("push") + public Map push( Map map){ + log.info("------接收GET回调-------"); + Map objectObjectHashMap = new HashMap<>(); + objectObjectHashMap.put("message","ok"); + return objectObjectHashMap; + } + + @PostMapping("push") + public Map PostPush( + @RequestParam("ciphertext") String ciphertext, + @RequestParam("nonce") String nonce, + @RequestParam("tag") String tag, + @RequestParam("additional_data") String additional_data, + @RequestParam("iv") String iv, + @RequestParam("signature") String signature){ + log.info("------push-------"); + + return printerService.PostPush(ciphertext,nonce,tag,additional_data,iv,signature); + } + + @GetMapping("returnCode") + public ResponseObject returnCode(String payAmount) { + return getSuccessResult(printerService.returnCode(payAmount)); + } + +// +// public static final String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuiQQsY9lbZhtRoZIaBVN\n" + +// "XKuAme47UCUv3RG2AYJXKQ/TyXBBY0JULSf4637Ug7JqGR1ohHFpY9XotG5J/7Ne\n" + +// "safQApAz8QHKOa6+jqS0edafegjE7P0KqfQWvjUIbhAl5iXmiGLA/R6zLXxk8+PU\n" + +// "toRu1rmzMPCsbGRG0uHOZ0nYez1LSM4k4k8o4/dl7NDr2CqXrfYQCEvGAAJay/bg\n" + +// "h1B05cqFNuhQGvv55EX377QVZX7V0ZipIZhlzoh8pA0ZpzW/KndZ+pRYw6cPLvey\n" + +// "qymRnTlCSQUDYQRlxaDppPbZcU1Krb9tZUmhJp+R9l73tJX8yN5wzbq6HATZbD1v\n" + +// "BwIDAQAB"; + + +// @GetMapping("getToken") +// public ResponseObject getToken(){ +//// Methods.() +// //初始化控制器类 +// Methods m=Methods.getInstance(); +// //初始化终端信息 +// m.init("1038835098", "1595cb28ea30e98908e6334e735f4b8a"); +// //获取token +// m.getFreedomToken(); +// System.out.println("123123123123123"); +// return getSuccessResult(""); +// } + private static final String APP_KEY = "1073000501"; + private static final String APP_SECRET = "e0292ae66d9d21feaa895370d3a875aa"; + + // 授权 + @GetMapping("scancodemodel") + public ResponseObject scancodemodel(){ + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + String token = printerService.getToken(nowAccountInfo.getStoreId()); +// String token = printerService.getToken(138); + return getSuccessResult(token); + + } + + // 发起网络支付 + @GetMapping("printIndex") + public ResponseObject printIndex(BigDecimal payAmount) { + + + +// Methods m=Methods.getInstance(); +// m.init("26845ee50f13467cacbaa099489a2fc152abd6f5"); +// +// m.init(APP_KEY, APP_SECRET); +// +//// m.addPrinter("4004872261", "628023865417"); +// Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); +// HashMap objectObjectHashMap = new HashMap<>(); +//// {"order_payment":{"pay_amount":"支付金额","pay_amount_source":3},"processed_state":0} +// +// +// Map orderPaymentMap = new HashMap<>(); +// orderPaymentMap.put("pay_amount", payAmount); +//// orderPaymentMap.put("pay_amount", 0.01); +// orderPaymentMap.put("pay_amount_source", 3); +// +// Map processedStateMap = new HashMap<>(); +// processedStateMap.put("processed_state", 0); +// +// Map jsonDataMap = new HashMap<>(); +// jsonDataMap.put("order_payment", orderPaymentMap); +// jsonDataMap.putAll(processedStateMap); +// +// Gson gson = new GsonBuilder().setPrettyPrinting().create(); +// String json = gson.toJson(jsonDataMap); +// +// String a = ""+json+""; +// log.info("json:{}",a); +// +// String url=m.print("4004872261",a, System.currentTimeMillis()+random6.toString()); +// +// // 使用 Fastjson 将 JSON 字符串解析为 JSONObject +// JSONObject jsonObject = JSON.parseObject(url); +// +// // 将 JSONObject 转换为 Map +// Map map = jsonObject.getInnerMap(); +// //获取支付参数 +// log.info("url:{}",url); +// return getSuccessResult(map.get("error_description")); + String s = printerService.printIndex(payAmount, TokenUtil.getNowAccountInfo().getStoreId()); + return getSuccessResult(s); + + } + + + @GetMapping("doGet") + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + Methods m=Methods.getInstance(); +// m.init(APP_KEY,APP_SECRET); + m.init("26845ee50f13467cacbaa099489a2fc152abd6f5"); + + + response.setContentType("text/html"); + PrintWriter out = response.getWriter(); + //测试数据 + List testList = new ArrayList(); + Test t1 = new Test("麻辣牛肉", 23.00, 1,"1"); + Test t2 = new Test("麻辣牛肉", 23.00, 2,"2"); + Test t3 = new Test("精品千层肚", 24.00, 3,"3"); + Test t4 = new Test("麻辣牛肉", 23.00, 2,"1"); + Test t5 = new Test("极品鲜毛肚", 26.00, 2,"1"); + Test t6 = new Test("极品鲜毛肚", 26.00, 1,"2"); + Test t7 = new Test("极品鲜毛肚", 26.00, 3,"2"); + Test t8 = new Test("极品鲜毛肚", 26.00, 1,"1"); + Test t9 = new Test("极品鲜毛肚", 26.00, 2,"3"); + testList.add(t1); + testList.add(t2); + testList.add(t3); + testList.add(t4); + testList.add(t5); + testList.add(t6); + testList.add(t7); + testList.add(t8); + testList.add(t9); + Prient.setTestList(testList); + + //关键代码,自己的程序发送请求 + //初始化控制器类 +// Methods m=Methods.getInstance(); + //初始化终端信息 + m.init(APP_KEY, APP_SECRET); + //获取token +// m.getFreedomToken(); + //刷新token +// m.refreshToken(); + //添加授权 + m.addPrinter("4004872261", "628023865417"); + //打印 + //终端编号 打印内容 订单号 + //生成6位随机数 + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print("4004872261", Prient.print(), "Z"+System.currentTimeMillis()+random6.toString()); + response.sendRedirect(url); + out.flush(); + out.close(); + } + + @PostMapping("getHandover") + public void getHandover(@RequestBody Map handover) { +// Methods m=Methods.getInstance(); +// m.init("26845ee50f13467cacbaa099489a2fc152abd6f5"); +// +// m.init(APP_KEY, APP_SECRET); +// Handover.setHandover(handover); +// // m.addPrinter("4004872261", "628023865417"); +// Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); +// String url=m.print("4004872261", Handover.printHandover(), "Z"+System.currentTimeMillis()+random6.toString()); + printerService.getHandover(handover,TokenUtil.getNowAccountInfo().getStoreId()); + } + + + /** + * 收银台商品打印 + * @param oilOrder + */ + @PostMapping("printOilOrderReport") + public void oilOrderReport(@RequestBody Map oilOrder) { +// log.info("handover:{}",handover.toString()); +// Methods m=Methods.getInstance(); +// m.init("26845ee50f13467cacbaa099489a2fc152abd6f5"); +// +// m.init(APP_KEY, APP_SECRET); +// PrintOilOrderReport.setHandover(handover); +// Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); +// String url=m.print("4004872261", PrintOilOrderReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + printerService.oilOrderReport(oilOrder,TokenUtil.getNowAccountInfo().getStoreId()); + + } + + @PostMapping("rePrintOilOrderReport") + public void reOilOrderReport(@RequestBody Map oilOrder) { + printerService.reOilOrderReport(oilOrder,TokenUtil.getNowAccountInfo().getStoreId()); + } + /** + * 余额充值订单 + * @param cardValue + */ + @PostMapping("printCardValueReport") + public void printCardValueReport(@RequestBody Map cardValue) { +// log.info("handover:{}",cardValue.toString()); +// Methods m=Methods.getInstance(); +// m.init("26845ee50f13467cacbaa099489a2fc152abd6f5"); +// +// m.init(APP_KEY, APP_SECRET); +// PrintCardValueReport.setHandover(cardValue); +// Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); +// String url=m.print("4004872261", PrintCardValueReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + printerService.printCardValueReport(cardValue, TokenUtil.getNowAccountInfo().getStoreId()); + + } + /** + * 油卡充值订单 + * @param fuelDiesel + */ + @PostMapping("printFuelDieselReport") + public void printFuelDieselReport(@RequestBody Map fuelDiesel) { +// log.info("handover:{}",fuelDiesel.toString()); +// Methods m=Methods.getInstance(); +// m.init("26845ee50f13467cacbaa099489a2fc152abd6f5"); +// +// m.init(APP_KEY, APP_SECRET); +// PrintFuelDieselReport.setHandover(fuelDiesel); +// Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); +// String url=m.print("4004872261", PrintFuelDieselReport.printFeulOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + printerService.printFuelDieselReport(fuelDiesel,TokenUtil.getNowAccountInfo().getStoreId()); + + } + @PostMapping("printIntegralReport") + public void printIntegralReport(@RequestBody Map integral) { + printerService.printIntegralReport(integral,TokenUtil.getNowAccountInfo().getStoreId()); + + } + + @GetMapping("posPrinter") + public void posPrinter() { +// printRegisterReceiver(); +// Intent intent=new Intent(); +// +// new ComponentName(); + } + + + + + +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/impl/PrinterServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/impl/PrinterServiceImpl.java new file mode 100644 index 000000000..91276ef65 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/printer/service/impl/PrinterServiceImpl.java @@ -0,0 +1,480 @@ +package com.fuint.business.printer.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.internal.util.codec.Base64; +import com.fuint.business.printer.entity.PrintDeviceInfo; +import com.fuint.business.printer.mapper.PrintDeviceInfoMapper; +import com.fuint.business.printer.service.PrintDeviceInfoService; +import com.fuint.business.printer.service.PrinterService; +import com.fuint.business.printer.template.*; +import com.fuint.business.printer.unit.Methods; +import com.fuint.business.printer.vo.OrderPayment; +import com.fuint.common.util.RedisUtil; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.yly.print_sdk_library.RequestMethod; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.annotation.Resource; +import javax.crypto.Cipher; +import javax.crypto.spec.GCMParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.Signature; +import java.security.spec.X509EncodedKeySpec; +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Service +public class PrinterServiceImpl implements PrinterService { + + private static String code = new String(); + + public static final String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuiQQsY9lbZhtRoZIaBVN\n" + + "XKuAme47UCUv3RG2AYJXKQ/TyXBBY0JULSf4637Ug7JqGR1ohHFpY9XotG5J/7Ne\n" + + "safQApAz8QHKOa6+jqS0edafegjE7P0KqfQWvjUIbhAl5iXmiGLA/R6zLXxk8+PU\n" + + "toRu1rmzMPCsbGRG0uHOZ0nYez1LSM4k4k8o4/dl7NDr2CqXrfYQCEvGAAJay/bg\n" + + "h1B05cqFNuhQGvv55EX377QVZX7V0ZipIZhlzoh8pA0ZpzW/KndZ+pRYw6cPLvey\n" + + "qymRnTlCSQUDYQRlxaDppPbZcU1Krb9tZUmhJp+R9l73tJX8yN5wzbq6HATZbD1v\n" + + "BwIDAQAB"; + + + @Resource + PrintDeviceInfoService printDeviceInfoService; + @Resource + PrintDeviceInfoMapper printDeviceInfoMapper; + + @Override + public Map PostPush(String ciphertext, String nonce, String tag, String additional_data, String iv, String signature) { + System.out.println("PostMapping"+ciphertext); + code = new String(); + Map objectObjectHashMap = new HashMap<>(); + objectObjectHashMap.put("message","ok"); + verifySign(ciphertext,signature); + try { + String decrypte = decrypte(ciphertext, iv, tag); + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(decrypte); + + log.info("--回调支付--{}",jsonObject); + // 将 JSONObject 转换为 Map + Map map = jsonObject.getInnerMap(); + //获取支付参数 +// Map orderPaymentMap = (Map) map.get("order_payment"); + Map orderPaymentMap = (Map) map.get("order_other"); + log.info("--回调支付--{}",orderPaymentMap.get("scanned_code").toString()); + + OrderPayment orderPayment = new OrderPayment(); +// orderPayment.setOrderPayment(orderPaymentMap.get("pay_amount").toString()); + orderPayment.setScannedCode(orderPaymentMap.get("scanned_code").toString()); + +// RedisUtil.set(orderPaymentMap.get("scanned_code").toString(), orderPaymentMap.get("pay_amount").toString(), 100); + RedisUtil.set(orderPaymentMap.get("scanned_code").toString(), 100); + code = orderPaymentMap.get("scanned_code").toString(); + log.info("--获取打印回调--{}",jsonObject); + } catch (Exception e) { + throw new RuntimeException(e); + } + return objectObjectHashMap; + } + + @Override + public String returnCode(String payAmount) { + String thisCode = code; + code = new String(); + if (ObjectUtil.isEmpty(thisCode)) { + return "300"; + } + // if (RedisUtil.get(thisCode)) { + return thisCode; + // }else { + // return getSuccessResult("301"); + // } + + } + + + @Override + public String getToken(Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + if (ObjectUtil.isEmpty(infoByStoreId)){ + return "error"; + } + RequestMethod.getInstance().init(infoByStoreId.getAppKey(),infoByStoreId.getAppSecret()); + + try { +// String resJson = RequestMethod.getInstance().scanCodeModel_msign("4004872261", "628023865417"); + String resJson = RequestMethod.getInstance().scanCodeModel_msign(infoByStoreId.getMachineCode(), infoByStoreId.getMsign()); + log.info("--yilianyunAccessToken--{}",resJson); + + JSONObject jsonObject = JSONObject.parseObject(resJson); + String errorDescription = jsonObject.getString("error_description"); // success + if ("success".equals(errorDescription)) { + JSONObject body = jsonObject.getJSONObject("body"); + String accessToken = body.getString("access_token"); + RedisUtil.set("scancodemodel+"+storeId,accessToken,60*60*24); + return accessToken; + } + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + return "error"; + } + + + @Override + public String printIndex(BigDecimal payAmount,Integer storeId){ + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } + } + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + +// HashMap objectObjectHashMap = new HashMap<>(); + Map orderPaymentMap = new HashMap<>(); + orderPaymentMap.put("pay_amount", payAmount.toString()); +// orderPaymentMap.put("pay_amount", 0.01); + + orderPaymentMap.put("pay_amount_source", 3); + Map processedStateMap = new HashMap<>(); + processedStateMap.put("processed_state", 0); + Map jsonDataMap = new HashMap<>(); + jsonDataMap.put("order_payment", orderPaymentMap); + jsonDataMap.putAll(processedStateMap); + + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + String json = gson.toJson(jsonDataMap); + + String jsonData = ""+json+""; +// String jsonData = "{\"order_payment\":{\"pay_amount\":\"1\",\"pay_amount_source\":3},\"processed_state\":0}"; + log.info("json:{}",jsonData); + + String url=m.print(infoByStoreId.getMachineCode(),jsonData, System.currentTimeMillis()+random6.toString()); + + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(url); + + // 将 JSONObject 转换为 Map + Map map = jsonObject.getInnerMap(); + //获取支付参数 + log.info("url:{}",url); + if (ObjectUtil.isNotEmpty(url)) { + String error = jsonObject.getString("error"); + if ("18".equals(error)) { + getToken(storeId); + printIndex(payAmount,storeId); + } + + } + return map.get("error_description").toString(); + } + + // 打印交接班 + public void getHandover(Map handover,Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } + } + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); + Handover.setHandover(handover); + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print(infoByStoreId.getMachineCode(), Handover.printHandover(), "Z"+System.currentTimeMillis()+random6.toString()); + + } + + public void oilOrderReport(Map oilOrder,Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } } + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); + PrintOilOrderReport.setHandover(oilOrder); + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print(infoByStoreId.getMachineCode(), PrintOilOrderReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + if (ObjectUtil.isNotEmpty(url)) { + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(url); + + String error = jsonObject.getString("error"); + if ("18".equals(error)) { + getToken(storeId); + reOilOrderReport(oilOrder,storeId); + } + + } + } + public void reOilOrderReport(Map oilOrder,Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } + } + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); + RePrintOilOrderReport.setHandover(oilOrder); + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print(infoByStoreId.getMachineCode(), RePrintOilOrderReport.rePrintOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + if (ObjectUtil.isNotEmpty(url)) { + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(url); + + String error = jsonObject.getString("error"); + if ("18".equals(error)) { + getToken(storeId); + reOilOrderReport(oilOrder,storeId); + } + + } + + } + + public void printCardValueReport(Map cardValue,Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + + log.info("handover:{}",cardValue.toString()); + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } + } + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); + PrintCardValueReport.setHandover(cardValue); + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print(infoByStoreId.getMachineCode(), PrintCardValueReport.printOilOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + if (ObjectUtil.isNotEmpty(url)) { + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(url); + + String error = jsonObject.getString("error"); + if ("18".equals(error)) { + getToken(storeId); + reOilOrderReport(cardValue,storeId); + } + + } + } + public void printFuelDieselReport(Map fuelDiesel,Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + + log.info("handover:{}",fuelDiesel.toString()); + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } + } + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); + PrintFuelDieselReport.setHandover(fuelDiesel); + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print(infoByStoreId.getMachineCode(), PrintFuelDieselReport.printFeulOrder(), "Z"+System.currentTimeMillis()+random6.toString()); + if (ObjectUtil.isNotEmpty(url)) { + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(url); + + String error = jsonObject.getString("error"); + if ("18".equals(error)) { + getToken(storeId); + reOilOrderReport(fuelDiesel,storeId); + } + + } + } + + public void printIntegralReport(Map integral,Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + + log.info("handover:{}",integral.toString()); + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } + } + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); + PrintIntegralReport.setHandover(integral); + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print(infoByStoreId.getMachineCode(), PrintIntegralReport.printIntegral(), "Z"+System.currentTimeMillis()+random6.toString()); + if (ObjectUtil.isNotEmpty(url)) { + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(url); + + String error = jsonObject.getString("error"); + if ("18".equals(error)) { + getToken(storeId); + reOilOrderReport(integral,storeId); + } + + } + } + public void printTagReport(Map integral,Integer storeId) { + PrintDeviceInfo infoByStoreId = printDeviceInfoMapper.getInfoByStoreId(storeId); + + log.info("handover:{}",integral.toString()); + Methods m=Methods.getInstance(); + Object accessToken = RedisUtil.get("scancodemodel+" + storeId); + if (ObjectUtil.isNotEmpty(accessToken)) { + m.init(accessToken.toString()); + } else { + String token = getToken(storeId); + if ("error".equals(token)) { + throw new RuntimeException("获取参数失败,无法打印"); + }else { + m.init(token); + } + } + m.init(infoByStoreId.getAppKey(), infoByStoreId.getAppSecret()); +// PrintIntegralReport.setHandover(integral); + + StringBuilder sb=new StringBuilder(); + sb.append("
收款码打印\r\n
"); + sb.append("------------------------------------\r\n"); + sb.append("油枪:¥"+integral.get("gunName")+"\r\n"); + sb.append("升数:¥"+integral.get("oilNum")+"\r\n"); + sb.append("价格:¥"+integral.get("payAmount")+"\r\n"); + sb.append("------------------------------------\r\n"); + sb.append("
谢谢惠顾,欢迎下次光临!
"); + + Integer random6 = (int) ((Math.random() * 9 + 1) * 100000); + String url=m.print(infoByStoreId.getMachineCode(), sb.toString(), "Z"+System.currentTimeMillis()+random6.toString()); + if (ObjectUtil.isNotEmpty(url)) { + // 使用 Fastjson 将 JSON 字符串解析为 JSONObject + JSONObject jsonObject = JSON.parseObject(url); + + String error = jsonObject.getString("error"); + if ("18".equals(error)) { + getToken(storeId); + reOilOrderReport(integral,storeId); + } + + } + } + + + public void verifySign(String ciphertext, String signature) { + // 交易报文中ciphertext与signature + byte[] signatureByte = Base64.decodeBase64String(signature); + byte[] publicKeyByte = Base64.decodeBase64String(publicKey); + try { + System.out.println("验签结果:" + verify(ciphertext.getBytes(), signatureByte, publicKeyByte)); + boolean verify = verify(ciphertext.getBytes(), signatureByte, publicKeyByte); + } catch (GeneralSecurityException e) { + e.printStackTrace(); + } + } + + /** + * 第二步:解析参数 + */ + public String decrypte(String ciphertext, + String iv, + String tag) throws Exception { + // 交易报文中ciphertext与tag和iv +// String ciphertext = ""; +// String tag = ""; +// String iv = ""; + // 应用设置 -> K8推送 -> 设置 -> 接口加签名方式(密钥) -> 应用公钥 + String key = "e0292ae66d9d21feaa895370d3a875aa"; + try { + String plaintext = decrypte(Base64.decodeBase64String(ciphertext), key.getBytes(), iv.getBytes(), Base64.decodeBase64String(tag)); + System.out.println(plaintext); + return plaintext; + } catch (Exception e) { + throw new Exception(e); + } + } + + private static boolean verify(byte[] data, byte[] signature, byte[] publicKey) throws GeneralSecurityException { + X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(publicKey); + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + PublicKey pubKey = keyFactory.generatePublic(pubKeySpec); + Signature sig = Signature.getInstance("SHA256withRSA"); + sig.initVerify(pubKey); + sig.update(data); + return sig.verify(signature); + } + + /** + * AES-GCM-256对称解密 + */ + private static String decrypte(byte[] encryptedBytes, byte[] keyBytes, byte[] ivBytes, byte[] tagBytes) throws Exception { + + SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES"); + Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); + GCMParameterSpec gcmParameterSpec = new GCMParameterSpec(128, ivBytes); + cipher.init(Cipher.DECRYPT_MODE, secretKey, gcmParameterSpec); + cipher.updateAAD("transaction".getBytes(StandardCharsets.UTF_8)); + cipher.update(encryptedBytes); + byte[] decryptedBytes = cipher.doFinal(tagBytes); + String decryptedString = new String(decryptedBytes, StandardCharsets.UTF_8); + byte[] content = Base64.decodeBase64String(decryptedString); + return new String(content); + } + +} diff --git a/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java b/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java index 6043c309b..7f2ce6144 100644 --- a/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java +++ b/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java @@ -51,6 +51,7 @@ public class MtUser implements Serializable { @ApiModelProperty("证件号码") private String idcard; + @TableField(exist = false) @ApiModelProperty("等级ID") private String gradeId; // @@ -81,7 +82,7 @@ public class MtUser implements Serializable { @ApiModelProperty("来源渠道") private String source; - + @TableField(exist = false) @ApiModelProperty("密码") private String password; diff --git a/fuintBackend/lib/M1AIDL.jar b/fuintBackend/lib/M1AIDL.jar new file mode 100644 index 000000000..cf8b9cc78 Binary files /dev/null and b/fuintBackend/lib/M1AIDL.jar differ diff --git a/fuintBackend/lib/PrintAIDL.jar b/fuintBackend/lib/PrintAIDL.jar new file mode 100644 index 000000000..90f147938 Binary files /dev/null and b/fuintBackend/lib/PrintAIDL.jar differ diff --git a/fuintCashierWeb/src/views/details/index.vue b/fuintCashierWeb/src/views/details/index.vue index 616885019..2c9363c97 100644 --- a/fuintCashierWeb/src/views/details/index.vue +++ b/fuintCashierWeb/src/views/details/index.vue @@ -175,7 +175,6 @@
赠送{{ item.giftBalance }}
-
diff --git a/pos-uni/.hbuilderx/launch.json b/pos-uni/.hbuilderx/launch.json index ee5be7746..07d928111 100644 --- a/pos-uni/.hbuilderx/launch.json +++ b/pos-uni/.hbuilderx/launch.json @@ -1,20 +1,23 @@ -{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ - // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 - "version": "0.0", - "configurations": [{ - "app-plus" : - { - "launchtype" : "local" - }, - "default" : - { - "launchtype" : "local" - }, - "mp-weixin" : - { - "launchtype" : "local" - }, - "type" : "uniCloud" - } +{ + // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ + // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 + "version" : "0.0", + "configurations" : [ + { + "app-plus" : { + "launchtype" : "local" + }, + "default" : { + "launchtype" : "local" + }, + "mp-weixin" : { + "launchtype" : "local" + }, + "type" : "uniCloud" + }, + { + "playground" : "standard", + "type" : "uni-app:app-android" + } ] } diff --git a/pos-uni/components/header/headers.vue b/pos-uni/components/header/headers.vue index 929dbfcea..7805f6d72 100644 --- a/pos-uni/components/header/headers.vue +++ b/pos-uni/components/header/headers.vue @@ -5,7 +5,10 @@ {{titles}} - + + {{type?'筛选':''}} + + @@ -18,7 +21,8 @@ } }, props: { - titles: String + titles: String, + type: String }, mounted() { @@ -26,10 +30,13 @@ methods: { gobock() { uni.navigateBack() + }, + clickChild() { + console.log("2222222222222222222222222") + this.$emit('chiledEvent', 123); } } - } @@ -51,7 +58,7 @@ top: 0px; .my-icons { - width: 20px; + width: 50px; } diff --git a/pos-uni/pages.json b/pos-uni/pages.json index e5b1a0332..4effa8aec 100644 --- a/pos-uni/pages.json +++ b/pos-uni/pages.json @@ -92,6 +92,27 @@ "navigationStyle": "custom" } }, + { + "path": "outher/serviceList", + "style": { + "navigationBarTitleText": "服务条款", + "navigationStyle": "custom" + } + }, + { + "path": "outher/my", + "style": { + "navigationBarTitleText": "关于我们", + "navigationStyle": "custom" + } + }, + { + "path": "outher/yinsi", + "style": { + "navigationBarTitleText": "隐私协议", + "navigationStyle": "custom" + } + }, { "path": "PaymentCode/PaymentCode", "style": { diff --git a/pos-uni/pages/index/index.vue b/pos-uni/pages/index/index.vue index 5fa2ebbb9..b37f0c6e8 100644 --- a/pos-uni/pages/index/index.vue +++ b/pos-uni/pages/index/index.vue @@ -62,11 +62,34 @@ - + + + + + 已支付 + 已退款 + 未支付 + + + + 订单号: {{item.orderNo}} + + 油号:{{item.oilName}} + 升数:{{item.shengshu}}L + 下单时间:{{item.payTime}} + + 应付:¥{{item.goodsMoney}} + 优惠:¥0.00 + + + + 实付:¥{{item.payMoney}} + @@ -83,16 +106,26 @@ List: [], show: false, status: 'loading', + orderList: [], indexData: { totalPayMoney: '0', totalCount: '0', totalRefund: '0', - } + }, + form: { + page: 1, + pageSize: 10, + status: '', + startTime: '', + endTime: '', + payType: '' + }, } }, onShow() { // this.actList = ["1", "1", "1", "1", "1", ] // this.status = "nomore" 底部刷新结束 + this.getPageListByPos() this.getIndexData(); }, onPullDownRefresh() { @@ -110,6 +143,24 @@ tabbar }, methods: { + getPageListByPos() { + + + request({ + url: 'business/allOrderInfo/getPageListByPosRecentThree', + method: 'get', + params: this.form + }).then((res) => { + if (res.code == 200) { + this.orderList = res.data.records; + } else { + uni.showToast({ + title: res.data, + icon: "none" + }) + } + }) + }, goRecharge() { uni.navigateTo({ url: "/pagesHome/MemberRecharge/MemberRecharge" @@ -117,7 +168,7 @@ }, goCode() { uni.navigateTo({ - url: '/pagesHome/PaymentCode/PaymentCode' + url: '/pagesHome/PaymentCode/SetUpCode' }) }, gochangeShifts() { @@ -294,4 +345,122 @@ overflow: hidden; margin-left: 10px; } + + .box_ { + width: 95%; + border-radius: 8px; + background: #fff; + box-sizing: border-box; + padding: 15px; + margin: 15px auto; + + } + + .b-bx { + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; + } + + .title_ { + font-weight: bold; + font-size: 16px; + color: #333333; + } + + .zt-size { + font-weight: bold; + font-size: 16px; + color: #FD504E; + } + + .centne { + display: flex; + } + + .touxiang { + width: 60px; + height: 60px; + border-radius: 50%; + background: #D9D9D9; + margin-right: 15px; + } + + .right-centne { + width: 100%; + font-size: 14px; + } + + .h_ { + width: 100%; + margin-bottom: 5px; + } + + .end-box { + width: 100%; + text-align: right; + font-weight: bold; + font-size: 16px; + color: #0864E9; + } + + .time { + font-weight: 500; + font-size: 14px; + color: #333333; + margin: 0px auto; + margin-top: 15px; + } + + .time-bs { + width: 100%; + box-sizing: border-box; + background: #FFFFFF; + padding: 15px; + display: flex; + align-items: center; + justify-content: space-around; + } + + .time-bs2 { + width: 100%; + box-sizing: border-box; + background: #FFFFFF; + padding: 30px; + // display: flex; + align-items: center; + justify-content: space-around; + } + + .time-box { + border: 1px solid #0864E9; + box-sizing: border-box; + padding: 5px 15px; + border-radius: 8px; + font-size: 14px; + color: #333; + display: flex; + align-items: center; + justify-content: center; + } + + .time-box2 { + border: 1px solid #0864E9; + box-sizing: border-box; + padding: 5px 15px; + border-radius: 8px; + font-size: 14px; + color: #333; + display: flex; + align-items: center; + justify-content: center; + } + + .hao_ { + width: 30%; + font-weight: bold; + margin-right: 5px; + } \ No newline at end of file diff --git a/pos-uni/pages/my/my.vue b/pos-uni/pages/my/my.vue index 79cdbee96..d2f77ae9f 100644 --- a/pos-uni/pages/my/my.vue +++ b/pos-uni/pages/my/my.vue @@ -17,19 +17,24 @@ - + + + 服务条款 - + 关于我们 - + 隐私协议 @@ -107,6 +112,23 @@ }, goback() { uni.navigateBack() + }, + goServiceList() { + uni.navigateTo({ + url: '/pagesHome/outher/serviceList' + }) + }, + + goMyList() { + uni.navigateTo({ + url: '/pagesHome/outher/my' + }) + }, + + goYinsi() { + uni.navigateTo({ + url: '/pagesHome/outher/yinsi' + }) } } } diff --git a/pos-uni/pagesHome/AddVip/AddCode.vue b/pos-uni/pagesHome/AddVip/AddCode.vue index 88d56dfea..9bd90397e 100644 --- a/pos-uni/pagesHome/AddVip/AddCode.vue +++ b/pos-uni/pagesHome/AddVip/AddCode.vue @@ -25,6 +25,8 @@ @@ -209,11 +344,12 @@ } .right-centne { - width: 70%; + width: 100%; font-size: 14px; } .h_ { + width: 100%; margin-bottom: 5px; } @@ -224,4 +360,62 @@ font-size: 16px; color: #0864E9; } + + .time { + font-weight: 500; + font-size: 14px; + color: #333333; + margin: 0px auto; + margin-top: 15px; + } + + .time-bs { + width: 100%; + box-sizing: border-box; + background: #FFFFFF; + padding: 15px; + display: flex; + align-items: center; + justify-content: space-around; + } + + .time-bs2 { + width: 100%; + box-sizing: border-box; + background: #FFFFFF; + padding: 30px; + // display: flex; + align-items: center; + justify-content: space-around; + } + + .time-box { + border: 1px solid #0864E9; + box-sizing: border-box; + padding: 5px 15px; + border-radius: 8px; + font-size: 14px; + color: #333; + display: flex; + align-items: center; + justify-content: center; + } + + .time-box2 { + border: 1px solid #0864E9; + box-sizing: border-box; + padding: 5px 15px; + border-radius: 8px; + font-size: 14px; + color: #333; + display: flex; + align-items: center; + justify-content: center; + } + + .hao_ { + width: 30%; + font-weight: bold; + margin-right: 5px; + } \ No newline at end of file diff --git a/pos-uni/pagesHome/outher/my.vue b/pos-uni/pagesHome/outher/my.vue new file mode 100644 index 000000000..756b12388 --- /dev/null +++ b/pos-uni/pagesHome/outher/my.vue @@ -0,0 +1,247 @@ + + + + + \ No newline at end of file diff --git a/pos-uni/pagesHome/outher/serviceList.vue b/pos-uni/pagesHome/outher/serviceList.vue new file mode 100644 index 000000000..2d74eb386 --- /dev/null +++ b/pos-uni/pagesHome/outher/serviceList.vue @@ -0,0 +1,249 @@ + + + + + \ No newline at end of file diff --git a/pos-uni/pagesHome/outher/yinsi.vue b/pos-uni/pagesHome/outher/yinsi.vue new file mode 100644 index 000000000..cf0f906d5 --- /dev/null +++ b/pos-uni/pagesHome/outher/yinsi.vue @@ -0,0 +1,247 @@ + + + + + \ No newline at end of file diff --git a/pos-uni/pagesHome/searchVip/searchVip.vue b/pos-uni/pagesHome/searchVip/searchVip.vue index 1e9e5a37f..629cd3b02 100644 --- a/pos-uni/pagesHome/searchVip/searchVip.vue +++ b/pos-uni/pagesHome/searchVip/searchVip.vue @@ -52,17 +52,19 @@ return { titles: "会员查询", // 会员列表 - list:[], - total:0, - paramsQuery:{ - page:1, - pageSize:30, + list: [], + total: 0, + paramsQuery: { + page: 1, + pageSize: 30, }, - AmountCollected:"", + AmountCollected: "", + type: "", } }, onLoad(e) { this.AmountCollected = e.AmountCollected + this.type = e.type }, onShow() { // this.actList = ["1", "1", "1", "1", "1", ] @@ -87,12 +89,20 @@ headers }, methods: { - toCollection(id){ - uni.navigateTo({ - url:"/pagesHome/Collection/Collection?userId="+id+"&AmountCollected="+this.AmountCollected - }) + toCollection(id) { + if (this.type && this.type == 1) { + uni.navigateTo({ + url: "/pagesHome/MemberRecharge/MemberRecharge?userId=" + id + }) + } else { + uni.navigateTo({ + url: "/pagesHome/Collection/Collection?userId=" + id + "&AmountCollected=" + this + .AmountCollected + }) + } + }, - getList(){ + getList() { request({ url: '/business/userManager/user/list', method: 'get', @@ -105,7 +115,7 @@ } this.total = res.data.total }) - + }, govipjs() { uni.navigateTo({ diff --git a/pos-uni/static/imgs/zfsb.png b/pos-uni/static/imgs/zfsb.png new file mode 100644 index 000000000..398493507 Binary files /dev/null and b/pos-uni/static/imgs/zfsb.png differ