|
@@ -193,9 +193,8 @@ public class TOrderController {
|
|
|
return JsonMessage.error("参数错误");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Long equipmentId = equipment.getId();
|
|
|
- //查找商品
|
|
|
+ // 查找商品
|
|
|
ResponseModel<TProduct> product1 = szwlFeign.getProduct(String.valueOf(equipmentId), productName);
|
|
|
TProduct product = product1.getData();
|
|
|
if (product == null) {
|
|
@@ -1946,6 +1945,880 @@ public class TOrderController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 冰淇淋请求在线支付 主扫 优惠码 二码合一
|
|
|
+ *
|
|
|
+ * @param clientId 设备唯一编号
|
|
|
+ * @param productName 商品名称:"冰淇淋-草莓酱,榛子碎"
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "请求在线支付 二码合一")
|
|
|
+ @GetMapping("/iceCreamTwoPay")
|
|
|
+ public Object iceCreamTwoPay(String code, String clientId, String productName) {
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
+ if(equipment==null||equipment.getId()==null){
|
|
|
+ return JsonMessage.error("找不到设备");
|
|
|
+ }
|
|
|
+ //验证优惠码 code=null 则不选用优惠码
|
|
|
+ TPromoCode promoCode = new TPromoCode();
|
|
|
+ if(StringUtils.isEmpty(code)){
|
|
|
+ //没有优惠码
|
|
|
+ }else {
|
|
|
+ //有优惠码,需要对优惠码进行验证
|
|
|
+ ResponseModel<TPromoCode> tPromoCodeResponseModel = szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString());
|
|
|
+ TPromoCode tPromoCode = tPromoCodeResponseModel.getData();
|
|
|
+ promoCode = tPromoCode;
|
|
|
+ if (tPromoCode == null||tPromoCode.getId()==null) {
|
|
|
+ //不存在
|
|
|
+ return JsonMessage.success("1");
|
|
|
+ }
|
|
|
+ if (promoCode.getId() == null) {
|
|
|
+ //不存在
|
|
|
+ return JsonMessage.success("1");
|
|
|
+ }
|
|
|
+ Date lastUseDate = null;
|
|
|
+ if (promoCode != null&&promoCode.getId()!=null) {
|
|
|
+ lastUseDate = promoCode.getLastUseDate();
|
|
|
+ }
|
|
|
+ if (lastUseDate != null && lastUseDate.getTime() < ((new Date()).getTime())) {
|
|
|
+ promoCode.setIsUse("2");
|
|
|
+ szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()),"2");
|
|
|
+ //过期
|
|
|
+ return JsonMessage.success("4");
|
|
|
+ }
|
|
|
+ if (promoCode.getIsUse().equals("1")) {
|
|
|
+ //被使用
|
|
|
+ return JsonMessage.success("2");
|
|
|
+ }
|
|
|
+ if(!promoCode.getAdminId().equals("1")){
|
|
|
+ if (String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //不是本机
|
|
|
+ return JsonMessage.success("3");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (promoCode.getDiscount() == null) {
|
|
|
+ //旧优惠码
|
|
|
+ return JsonMessage.success("0");
|
|
|
+ }
|
|
|
+ if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
+ //0折
|
|
|
+ return JsonMessage.success("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (equipment == null) {
|
|
|
+ return JsonMessage.error("找不到设备");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long equipmentId = equipment.getId();
|
|
|
+ // 查找商品
|
|
|
+ String[] split = productName.split("-");
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), split[0]));
|
|
|
+ if (product == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+ // 处理后的商品名称
|
|
|
+ String newProductName = split[0];
|
|
|
+ // 冰淇淋价格
|
|
|
+ BigDecimal price = product.getRmbPrice();
|
|
|
+ // 商品ID
|
|
|
+ Long productId = product.getId();
|
|
|
+ // 冰淇淋编号
|
|
|
+ String productNo = product.getNo();
|
|
|
+ // 如果添加其他果酱和小料
|
|
|
+ if (split.length > 1) {
|
|
|
+ String[] split1 = split[1].split(",");
|
|
|
+ String tempName = "(";
|
|
|
+ for (String s : split1) {
|
|
|
+ TProduct product1 = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), s));
|
|
|
+ if (product1 == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+ tempName = tempName + s + "、";
|
|
|
+ price = price.add(product1.getRmbPrice());
|
|
|
+ }
|
|
|
+ tempName = tempName.substring(0 , tempName.length() - 1) +")";
|
|
|
+ newProductName += tempName;
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(code)){
|
|
|
+ BigDecimal discount = BigDecimal.valueOf(promoCode.getDiscount());
|
|
|
+ if (StringUtils.isNotEmpty(promoCode.getType()) && promoCode.getType().equals("1")) {
|
|
|
+ if (price.compareTo(discount) > 0) {
|
|
|
+ // 如果 price 大于 discount,从 price 中减去 discount
|
|
|
+ price = price.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ } else {
|
|
|
+ // 如果 price 小于等于 discount,将 price 设置为 0
|
|
|
+ price = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ price = price.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+ return JsonMessage.error("商品价格异常");
|
|
|
+ }
|
|
|
+ Long client6 = Long.parseLong(clientId.substring(clientId.length() - 6));
|
|
|
+ String sn1 = orderService.initSn(client6);
|
|
|
+ String sn2 = orderService.initSn(client6);
|
|
|
+ // 获取关联设备的分销
|
|
|
+ TProportion proportion = R.getDataIfSuccess(szwlFeign.getProportion(String.valueOf(equipmentId)));
|
|
|
+ if (proportion == null || proportion.getId()==null) {
|
|
|
+ return JsonMessage.error("设备商家未完成分销设置");
|
|
|
+ }
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(equipment.getAdminId())));
|
|
|
+ if (admin == null) {
|
|
|
+ return JsonMessage.error("找不到设备商家");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 支付方式:0或null为汇聚,1为汇付支付
|
|
|
+ String payPlatform = admin.getPayPlatform();
|
|
|
+ String companyType = admin.getCompanyType();
|
|
|
+ // 汇聚分账参数
|
|
|
+ JSONArray altInfo = new JSONArray();
|
|
|
+ // 汇付分账明细参数
|
|
|
+ JSONObject acctSplitBunch = new JSONObject();
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ acctSplitBunch = getAcctSplitBunch(proportion, price, companyType);
|
|
|
+ if (!(acctSplitBunch.size() > 0)) {
|
|
|
+ return JsonMessage.error("设备商家未注册结算账号");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ altInfo = getAltInfo(proportion, price);
|
|
|
+ if (!(altInfo.size() > 0)) {
|
|
|
+ return JsonMessage.error("设备商家未注册结算账号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String orderNo1 = sn1;
|
|
|
+ String orderNo2 = sn2;
|
|
|
+ BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ String productDesc = "";
|
|
|
+ String commonParameter = "";
|
|
|
+ String returnUrl = null;
|
|
|
+ String notifyUrl = JoinpayConstant.Notify_Url;
|
|
|
+ String isShowPic = "1";
|
|
|
+ String openId = null;
|
|
|
+ String authCode = null;
|
|
|
+ String appid = null;
|
|
|
+ String transactionModel = null;
|
|
|
+ String tradeMerchantNo = admin.getTradeMerchantNo();
|
|
|
+ String buyerId = null;
|
|
|
+ String isAlt = "1";
|
|
|
+ String altType = "11";
|
|
|
+ String altUrl = null;
|
|
|
+ BigDecimal marketingAmount = null;
|
|
|
+ String frpCode1 = "WEIXIN_NATIVE";
|
|
|
+ String frpCode2 = "ALIPAY_NATIVE";
|
|
|
+ Integer productNumber = 1;
|
|
|
+
|
|
|
+ TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
+ order.setCreateDate(new Date());
|
|
|
+ order.setModifyDate(new Date());
|
|
|
+ order.setAdminId(admin.getId());
|
|
|
+ order.setSn(sn1);
|
|
|
+ order.setProductId(productId);
|
|
|
+ order.setProductNo(productNo);
|
|
|
+ order.setProductName(newProductName);
|
|
|
+ order.setProductNumber(productNumber);
|
|
|
+ order.setPrice(price);
|
|
|
+ order.setClientId(equipment.getClientId());
|
|
|
+ order.setEquipmentId(equipmentId);
|
|
|
+ order.setFrpCode(frpCode1);
|
|
|
+ order.setAltInfo(altInfo.toString());
|
|
|
+ order.setStatus(0);
|
|
|
+ order.setType(admin.getType());
|
|
|
+ order.setCompanyType(companyType);
|
|
|
+ order.setMachineType(equipment.getMachineType());
|
|
|
+ if(admin.getType()==0){
|
|
|
+ order.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order.setAgencyId(proportion.getAgencyId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==1){
|
|
|
+ order.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order.setAgencyId(proportion.getAgencyId());
|
|
|
+ order.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order.setMerchantId(proportion.getMerchantId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==2){
|
|
|
+ order.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order.setAgencyId(proportion.getAgencyId());
|
|
|
+ order.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order.setMerchantId(proportion.getMerchantId());
|
|
|
+ order.setPersonageProportion(proportion.getPersonageProportion());
|
|
|
+ order.setPersonageId(proportion.getPersonageId());
|
|
|
+ }
|
|
|
+ order.setPayPlatform(payPlatform);
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ order.setIsSettlement("0");
|
|
|
+ }
|
|
|
+ TOrder order2 = new TOrder();
|
|
|
+ order2.setId(IDGenerator.orderID());
|
|
|
+ order2.setCreateDate(new Date());
|
|
|
+ order2.setModifyDate(new Date());
|
|
|
+ order2.setAdminId(admin.getId());
|
|
|
+ order2.setSn(sn2);
|
|
|
+ order2.setProductId(productId);
|
|
|
+ order2.setProductNo(productNo);
|
|
|
+ order2.setProductName(newProductName);
|
|
|
+ order2.setProductNumber(productNumber);
|
|
|
+ order2.setPrice(price);
|
|
|
+ order2.setClientId(equipment.getClientId());
|
|
|
+ order2.setEquipmentId(equipmentId);
|
|
|
+ order2.setFrpCode(frpCode2);
|
|
|
+ order2.setAltInfo(altInfo.toString());
|
|
|
+ order2.setStatus(0);
|
|
|
+ order2.setType(admin.getType());
|
|
|
+ order2.setPayPlatform(payPlatform);
|
|
|
+ order2.setCompanyType(companyType);
|
|
|
+ order2.setMachineType(equipment.getMachineType());
|
|
|
+ if(admin.getType()==0){
|
|
|
+ order2.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order2.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order2.setAgencyId(proportion.getAgencyId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==1){
|
|
|
+ order2.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order2.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order2.setAgencyId(proportion.getAgencyId());
|
|
|
+ order2.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order2.setMerchantId(proportion.getMerchantId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==2){
|
|
|
+ order2.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order2.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order2.setAgencyId(proportion.getAgencyId());
|
|
|
+ order2.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order2.setMerchantId(proportion.getMerchantId());
|
|
|
+ order2.setPersonageProportion(proportion.getPersonageProportion());
|
|
|
+ order2.setPersonageId(proportion.getPersonageId());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ order2.setIsSettlement("0");
|
|
|
+ }
|
|
|
+ // 订单明细表
|
|
|
+ TOrderDetails orderDetails = new TOrderDetails();
|
|
|
+ orderDetails.setAdminId(admin.getId());
|
|
|
+ orderDetails.setEquipmentId(equipmentId);
|
|
|
+ orderDetails.setCreateDate(new Date());
|
|
|
+ orderDetails.setPrice(price);
|
|
|
+ orderDetails.setProductName(newProductName);
|
|
|
+ orderDetails.setProductNo(productNo);
|
|
|
+ orderDetails.setProductNumber(productNumber);
|
|
|
+ orderDetails.setAmount(price);
|
|
|
+ orderDetails.setCompanyType(companyType);
|
|
|
+ orderDetails.setRefundStatus("0");
|
|
|
+ orderDetails.setMachineType(equipment.getMachineType());
|
|
|
+
|
|
|
+// String client6 = clientId.substring(clientId.length() - 6);
|
|
|
+ String productName1 = newProductName + "-" + equipment.getName() + "-" + client6;
|
|
|
+ String result = null;
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ // 汇付分账参数
|
|
|
+ order.setAcctSplitBunch(acctSplitBunch.toString());
|
|
|
+ order2.setAcctSplitBunch(acctSplitBunch.toString());
|
|
|
+ //添加到汇付临时表,微信
|
|
|
+ THuifuTempOrder tHuifuTempOrder = new THuifuTempOrder();
|
|
|
+ String[] ignoreProperties = {"id"};
|
|
|
+ String id = HuifuUtils.inithuifuTempId();
|
|
|
+ tHuifuTempOrder.setId(id);
|
|
|
+ BeanUtil.copyProperties(order,tHuifuTempOrder,ignoreProperties);
|
|
|
+ huifuTempOrderService.save(tHuifuTempOrder);
|
|
|
+ String result1 = "";
|
|
|
+ if (StrUtil.isNotEmpty(companyType)&&companyType.equals("1")) {
|
|
|
+ result1 = HuifuConstant.SC_JUMP_URL+ "/#/weChatPay?id=" + id;
|
|
|
+ } else {
|
|
|
+ result1 = HuifuConstant.SZ_JUMP_URL+ "/#/weChatPay?id=" + id;
|
|
|
+ }
|
|
|
+ // 支付宝
|
|
|
+ try {
|
|
|
+ result = huifuMchService.uniPay(
|
|
|
+ sn2, amount, productName1, productDesc,
|
|
|
+ notifyUrl, frpCode2, openId, appid, acctSplitBunch,companyType
|
|
|
+ );
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.error("申请支付失败");
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(result)) {
|
|
|
+ return JsonMessage.error("找不到支付图片");
|
|
|
+ }
|
|
|
+ // 汇聚支付支付申请返回支付二维码图片
|
|
|
+ String code1 = "http://sz.sunzee.com.cn/PAY-SERVER/tOrder/aliPay?zfb="+result+"&wx="+result1;
|
|
|
+ String qrcode = toQrcode(code1);
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn", sn1+"-"+sn2);
|
|
|
+ kindData.put("rd_Pic", qrcode);
|
|
|
+ orderDetails.setOrderSn(sn2);
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetailsService.save(orderDetails);
|
|
|
+ orderService.save(order2);
|
|
|
+ return JsonMessage.success(kindData.toString());
|
|
|
+ }else{
|
|
|
+ try {
|
|
|
+ result = joinpayMchService.uniPay(
|
|
|
+ orderNo1, amount, productName1, productDesc,
|
|
|
+ commonParameter, returnUrl, notifyUrl, frpCode1,
|
|
|
+ isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
|
|
|
+ buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
|
|
|
+ );
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.error("申请支付失败");
|
|
|
+ }
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ String rc_Result1 = resultJson.getString("rc_Result");
|
|
|
+ String result1 = null;
|
|
|
+ try {
|
|
|
+ result1 = joinpayMchService.uniPay(
|
|
|
+ orderNo2, amount, productName1, productDesc,
|
|
|
+ commonParameter, returnUrl, notifyUrl, frpCode2,
|
|
|
+ isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
|
|
|
+ buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
|
|
|
+ );
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.error("申请支付失败");
|
|
|
+ }
|
|
|
+ JSONObject resultJson1 = JSONObject.parseObject(result1);
|
|
|
+ String rc_Result2 = resultJson1.getString("rc_Result");
|
|
|
+
|
|
|
+ // 汇聚支付支付申请返回支付二维码图片
|
|
|
+ String code1 = "http://sz.sunzee.com.cn/PAY-SERVER/tOrder/"+"aliPay?wx="+rc_Result1+"&zfb="+rc_Result2;
|
|
|
+ String rd_Pic = toQrcode(code1);
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn", sn1+"-"+sn2);
|
|
|
+ kindData.put("rd_Pic", rd_Pic);
|
|
|
+ orderService.save(order);
|
|
|
+ orderDetails.setOrderSn(sn1);
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetailsService.save(orderDetails);
|
|
|
+ orderDetails.setOrderSn(sn2);
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetailsService.save(orderDetails);
|
|
|
+ orderService.save(order2);
|
|
|
+ return JsonMessage.success(kindData.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 冰淇淋购物车支付
|
|
|
+ *
|
|
|
+ * @param clientId 设备唯一编号
|
|
|
+ * @param productNameMap 商品信息:"冰淇淋-草莓酱,榛子碎-2": "[\"562278\",\"0\"]"
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "购物车 请求在线支付 二码合一")
|
|
|
+ @PostMapping("/iceCreamCarsPay")
|
|
|
+ public Object iceCreamCarsPay(String clientId, @RequestBody Map<String,String> productNameMap) {
|
|
|
+ if(productNameMap==null){
|
|
|
+ return JsonMessage.error("数据出错");
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuffer note = new StringBuffer();
|
|
|
+ StringBuffer productName = new StringBuffer();
|
|
|
+ String productNo = "";
|
|
|
+ Map<String, Integer> productMap = new HashMap<>();
|
|
|
+ Integer productNumber = 0;
|
|
|
+
|
|
|
+ TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
+ if(equipment==null||equipment.getId()==null){
|
|
|
+ return JsonMessage.error("找不到设备");
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal price = new BigDecimal("0.00");
|
|
|
+ TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
|
|
|
+ if(equipmentDesc==null||equipmentDesc.getEquipmentId()==null||equipmentDesc.getPayType()==null||equipmentDesc.getPayType().equals("0")){
|
|
|
+ // 1、type=0,原始设定,没有第二件半价
|
|
|
+ for (String key : productNameMap.keySet()) {
|
|
|
+ String entryValue = String.valueOf(productNameMap.get(key));
|
|
|
+ List<String> value = JSON.parseArray(entryValue, String.class);
|
|
|
+ List<TPromoCode> promoCodeList = new ArrayList<>();
|
|
|
+ // 1、校验优惠码
|
|
|
+ if(value.size()>0){
|
|
|
+ for(String code:value){
|
|
|
+ if(!code.equals("0")){
|
|
|
+ TPromoCode promoCode;
|
|
|
+ ResponseModel<TPromoCode> tPromoCodeResponseModel = szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString());
|
|
|
+ TPromoCode tPromoCode = tPromoCodeResponseModel.getData();
|
|
|
+ promoCode = tPromoCode;
|
|
|
+ if (tPromoCode == null||tPromoCode.getId()==null) {
|
|
|
+ //不存在
|
|
|
+ return JsonMessage.success("1");
|
|
|
+ }
|
|
|
+ Date lastUseDate = null;
|
|
|
+ if (promoCode != null) {
|
|
|
+ lastUseDate = promoCode.getLastUseDate();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (lastUseDate != null && lastUseDate.getTime() < ((new Date()).getTime())) {
|
|
|
+ promoCode.setIsUse("2");
|
|
|
+ szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()),"2");
|
|
|
+ //过期
|
|
|
+ return JsonMessage.success("4");
|
|
|
+ }
|
|
|
+ if (promoCode.getId() == null) {
|
|
|
+ //不存在
|
|
|
+ return JsonMessage.success("1");
|
|
|
+ }
|
|
|
+ if (promoCode.getIsUse().equals("1")) {
|
|
|
+ //被使用
|
|
|
+ return JsonMessage.success("2");
|
|
|
+ }
|
|
|
+ if(!promoCode.getAdminId().equals("1")){
|
|
|
+ if (String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //不是本机
|
|
|
+ return JsonMessage.success("3");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (promoCode.getDiscount() == null) {
|
|
|
+ //旧优惠码
|
|
|
+ return JsonMessage.success("0");
|
|
|
+ }
|
|
|
+ if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
+ //0折
|
|
|
+ return JsonMessage.success("0");
|
|
|
+ }
|
|
|
+ promoCodeList.add(promoCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String[] products = key.split("-");
|
|
|
+ String iceCreamName = products[0];
|
|
|
+ String num= products[1];
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), iceCreamName));
|
|
|
+ if (product == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+ productNo = product.getNo();
|
|
|
+ BigDecimal productPrice = product.getRmbPrice();
|
|
|
+ // 如果加了果酱或者小料
|
|
|
+ if (products.length > 2) {
|
|
|
+ // 商品数
|
|
|
+ num = products[2];
|
|
|
+ // 加料
|
|
|
+ String[] charge = products[1].split(",");
|
|
|
+ String tempName = "(";
|
|
|
+ for (String s : charge) {
|
|
|
+ TProduct product1 = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), s));
|
|
|
+ if (product1 == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+ tempName = tempName + s + "、";
|
|
|
+ productPrice = productPrice.add(product1.getRmbPrice());
|
|
|
+ }
|
|
|
+ tempName = tempName.substring(0 , tempName.length() - 1) + ")";
|
|
|
+ iceCreamName += tempName;
|
|
|
+ }
|
|
|
+ productMap.put(iceCreamName + "-" + productPrice,Integer.valueOf(num));
|
|
|
+ productNumber += Integer.valueOf(num);
|
|
|
+ productName.append(iceCreamName).append("x").append(num).append(",");
|
|
|
+ //确定价格,然后叠加
|
|
|
+ note.append(iceCreamName).append("-").append(product.getNo()).append(":");
|
|
|
+ if(promoCodeList.size()>0){
|
|
|
+ //有优惠码
|
|
|
+ BigDecimal onePrice = new BigDecimal("0.00");
|
|
|
+ int i;
|
|
|
+ for( i = 0;i<promoCodeList.size();i++){
|
|
|
+ BigDecimal discount = BigDecimal.valueOf(promoCodeList.get(i).getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ BigDecimal price1 = new BigDecimal(0.0);
|
|
|
+ if (StringUtils.isNotEmpty(promoCodeList.get(i).getType()) && promoCodeList.get(i).getType().equals("1")) {
|
|
|
+ if (productPrice.compareTo(discount) > 0) {
|
|
|
+ // 如果 price 大于 discount,从 price 中减去 discount
|
|
|
+ price1 = productPrice.subtract(discount).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ } else {
|
|
|
+ // 如果 price 小于等于 discount,将 price 设置为 0
|
|
|
+ price1 = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ }
|
|
|
+// BigDecimal price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ price = price.add(price1);
|
|
|
+ onePrice = onePrice.add(price1);
|
|
|
+ }
|
|
|
+ if(i<Integer.valueOf(num)){
|
|
|
+ int a = Integer.valueOf(num)-i;
|
|
|
+ BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ price =price.add(price2);
|
|
|
+ onePrice = onePrice.add(price2);
|
|
|
+ }
|
|
|
+ note.append(onePrice).append("-").append(num).append(",");
|
|
|
+ }else {
|
|
|
+ //1,type=0,原始设定,没有第二件半价
|
|
|
+ int a = Integer.valueOf(num);
|
|
|
+ BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ price =price.add(price2);
|
|
|
+ note.append(price2).append("-").append(num).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //2,type=1,第二件半价
|
|
|
+ //2.1 判定是否有第二件,有多少个第二件半价
|
|
|
+ for (String key : productNameMap.keySet()) {
|
|
|
+ String[] products = key.split("-");
|
|
|
+ String iceCreamName = products[0];
|
|
|
+ String num= products[1];
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), iceCreamName));
|
|
|
+ if (product == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+ productNo = product.getNo();
|
|
|
+ BigDecimal productPrice = product.getRmbPrice();
|
|
|
+ // 如果加了果酱或者小料
|
|
|
+ if (products.length > 2) {
|
|
|
+ // 商品数
|
|
|
+ num = products[2];
|
|
|
+ // 加料
|
|
|
+ String[] charge = products[1].split(",");
|
|
|
+ String tempName = "(";
|
|
|
+ for (String s : charge) {
|
|
|
+ TProduct product1 = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), s));
|
|
|
+ if (product1 == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+ tempName = tempName + s + "、";
|
|
|
+ productPrice = productPrice.add(product1.getRmbPrice());
|
|
|
+ }
|
|
|
+ tempName = tempName.substring(0 , tempName.length() - 1) + ")";
|
|
|
+ iceCreamName += tempName;
|
|
|
+ }
|
|
|
+ productMap.put(iceCreamName + "-" + productPrice,Integer.valueOf(num));
|
|
|
+ productName.append(iceCreamName).append("x").append(num).append(",");
|
|
|
+ note.append(iceCreamName).append("-").append(product.getNo()).append(":");
|
|
|
+ switch (num) {
|
|
|
+ case "1":
|
|
|
+ //1个 0个半价
|
|
|
+ price =price.add(productPrice);
|
|
|
+ note.append(price).append("-").append(num).append(",");
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ //2个 1个半价
|
|
|
+ price =price.add(productPrice);
|
|
|
+ price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ note.append(price).append("-").append(num).append(",");
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ //3个 1个半价
|
|
|
+ price =price.add(productPrice);
|
|
|
+ price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price =price.add(productPrice);
|
|
|
+ note.append(price).append("-").append(num).append(",");
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ //4个 2个半价
|
|
|
+ price =price.add(productPrice);
|
|
|
+ price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price =price.add(productPrice);
|
|
|
+ price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ note.append(price).append("-").append(num).append(",");
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ //5个 2个半价
|
|
|
+ price =price.add(productPrice);
|
|
|
+ price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price =price.add(productPrice);
|
|
|
+ price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price =price.add(productPrice);
|
|
|
+ note.append(price).append("-").append(num).append(",");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (equipment == null) {
|
|
|
+ return JsonMessage.error("找不到设备");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long equipmentId = equipment.getId();
|
|
|
+ //查找商品
|
|
|
+ if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+ return JsonMessage.error("商品价格异常");
|
|
|
+ }
|
|
|
+ Long client6 = Long.parseLong(clientId.substring(clientId.length() - 6));
|
|
|
+ String sn1 = orderService.initSn(client6);
|
|
|
+ String sn2 = orderService.initSn(client6);
|
|
|
+ // 获取关联设备的分销
|
|
|
+ TProportion proportion = R.getDataIfSuccess(szwlFeign.getProportion(String.valueOf(equipmentId)));
|
|
|
+ if (proportion == null || proportion.getId()==null) {
|
|
|
+ return JsonMessage.error("设备商家未完成分销设置");
|
|
|
+ }
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(equipment.getAdminId())));
|
|
|
+ if (admin == null) {
|
|
|
+ return JsonMessage.error("找不到设备商家");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 支付方式:0或null为汇聚,1为汇付支付
|
|
|
+ String payPlatform = admin.getPayPlatform();
|
|
|
+ String companyType = admin.getCompanyType();
|
|
|
+ // 汇聚分账参数
|
|
|
+ JSONArray altInfo = new JSONArray();
|
|
|
+ // 汇付分账明细参数
|
|
|
+ JSONObject acctSplitBunch = new JSONObject();
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ acctSplitBunch = getAcctSplitBunch(proportion, price, companyType);
|
|
|
+ if (!(acctSplitBunch.size() > 0)) {
|
|
|
+ return JsonMessage.error("设备商家未注册结算账号");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ altInfo = getAltInfo(proportion, price);
|
|
|
+ if (!(altInfo.size() > 0)) {
|
|
|
+ return JsonMessage.error("设备商家未注册结算账号");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String orderNo1 = sn1;
|
|
|
+ String orderNo2 = sn2;
|
|
|
+ BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ String productDesc = "";
|
|
|
+ String commonParameter = "";
|
|
|
+ String returnUrl = null;
|
|
|
+ String notifyUrl = JoinpayConstant.Notify_Url;
|
|
|
+ String isShowPic = "1";
|
|
|
+ String openId = null;
|
|
|
+ String authCode = null;
|
|
|
+ String appid = null;
|
|
|
+ String transactionModel = null;
|
|
|
+ String tradeMerchantNo = admin.getTradeMerchantNo();
|
|
|
+ String buyerId = null;
|
|
|
+ String isAlt = "1";
|
|
|
+ String altType = "11";
|
|
|
+ String altUrl = null;
|
|
|
+ BigDecimal marketingAmount = null;
|
|
|
+ String frpCode1 = "WEIXIN_NATIVE";
|
|
|
+ String frpCode2 = "ALIPAY_NATIVE";
|
|
|
+
|
|
|
+ TOrder order = new TOrder();
|
|
|
+ order.setId(IDGenerator.orderID());
|
|
|
+ order.setCreateDate(new Date());
|
|
|
+ order.setModifyDate(new Date());
|
|
|
+ order.setAdminId(admin.getId());
|
|
|
+ order.setSn(sn1);
|
|
|
+ // 去掉后面的逗号
|
|
|
+ order.setProductNo(productNo);
|
|
|
+ if(productNumber == 1) {
|
|
|
+ productName.delete(productName.length() - 3, productName.length());
|
|
|
+ } else {
|
|
|
+ productName.deleteCharAt(productName.length() - 1);
|
|
|
+ }
|
|
|
+ order.setProductName(productName.toString());
|
|
|
+ order.setPrice(price);
|
|
|
+ order.setClientId(equipment.getClientId());
|
|
|
+ order.setEquipmentId(equipmentId);
|
|
|
+ order.setFrpCode(frpCode1);
|
|
|
+ order.setAltInfo(altInfo.toString());
|
|
|
+ order.setProductNumber(productNumber);
|
|
|
+ order.setStatus(0);
|
|
|
+ order.setType(admin.getType());
|
|
|
+ order.setCompanyType(companyType);
|
|
|
+ order.setMachineType(equipment.getMachineType());
|
|
|
+ if(admin.getType()==0){
|
|
|
+ order.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order.setAgencyId(proportion.getAgencyId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==1){
|
|
|
+ order.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order.setAgencyId(proportion.getAgencyId());
|
|
|
+ order.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order.setMerchantId(proportion.getMerchantId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==2){
|
|
|
+ order.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order.setAgencyId(proportion.getAgencyId());
|
|
|
+ order.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order.setMerchantId(proportion.getMerchantId());
|
|
|
+ order.setPersonageProportion(proportion.getPersonageProportion());
|
|
|
+ order.setPersonageId(proportion.getPersonageId());
|
|
|
+ }
|
|
|
+ order.setPayPlatform(payPlatform);
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ order.setIsSettlement("0");
|
|
|
+ }
|
|
|
+ order.setNote(note.toString());
|
|
|
+ TOrder order2 = new TOrder();
|
|
|
+ order2.setId(IDGenerator.orderID());
|
|
|
+ order2.setCreateDate(new Date());
|
|
|
+ order2.setModifyDate(new Date());
|
|
|
+ order2.setAdminId(admin.getId());
|
|
|
+ order2.setSn(sn2);
|
|
|
+ order2.setProductName(productName.toString());
|
|
|
+ order2.setProductNo(productNo);
|
|
|
+ order2.setPrice(price);
|
|
|
+ order2.setClientId(equipment.getClientId());
|
|
|
+ order2.setEquipmentId(equipmentId);
|
|
|
+ order2.setFrpCode(frpCode2);
|
|
|
+ order2.setAltInfo(altInfo.toString());
|
|
|
+ order2.setStatus(0);
|
|
|
+ order2.setProductNumber(productNumber);
|
|
|
+ order2.setType(admin.getType());
|
|
|
+ order2.setCompanyType(companyType);
|
|
|
+ order2.setMachineType(equipment.getMachineType());
|
|
|
+ if(admin.getType()==0){
|
|
|
+ order2.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order2.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order2.setAgencyId(proportion.getAgencyId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==1){
|
|
|
+ order2.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order2.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order2.setAgencyId(proportion.getAgencyId());
|
|
|
+ order2.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order2.setMerchantId(proportion.getMerchantId());
|
|
|
+ }
|
|
|
+ if(admin.getType()==2){
|
|
|
+ order2.setAdminProportion(proportion.getAdminProportion());
|
|
|
+ order2.setAgencyProportion(proportion.getAgencyProportion());
|
|
|
+ order2.setAgencyId(proportion.getAgencyId());
|
|
|
+ order2.setMerchantProportion(proportion.getMerchantProportion());
|
|
|
+ order2.setMerchantId(proportion.getMerchantId());
|
|
|
+ order2.setPersonageProportion(proportion.getPersonageProportion());
|
|
|
+ order2.setPersonageId(proportion.getPersonageId());
|
|
|
+ }
|
|
|
+ order2.setPayPlatform(payPlatform);
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ order2.setIsSettlement("0");
|
|
|
+ }
|
|
|
+ order2.setNote(note.toString());
|
|
|
+ // 订单明细表
|
|
|
+ TOrderDetails orderDetails = new TOrderDetails();
|
|
|
+ orderDetails.setAdminId(admin.getId());
|
|
|
+ orderDetails.setEquipmentId(equipmentId);
|
|
|
+ orderDetails.setCreateDate(new Date());
|
|
|
+ orderDetails.setCompanyType(companyType);
|
|
|
+ orderDetails.setRefundStatus("0");
|
|
|
+ orderDetails.setMachineType(equipment.getMachineType());
|
|
|
+
|
|
|
+// String client6 = clientId.substring(clientId.length() - 6);
|
|
|
+ String productName1 = "";
|
|
|
+ if(productNumber > 1) {
|
|
|
+ productName1 = "冰淇淋-" + equipment.getName() + "-" + client6;
|
|
|
+ } else {
|
|
|
+ productName1 = productName + "-" + equipment.getName() + "-" + client6;
|
|
|
+ }
|
|
|
+ String result = null;
|
|
|
+ if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
+ // 汇付分账参数
|
|
|
+ order.setAcctSplitBunch(acctSplitBunch.toString());
|
|
|
+ order2.setAcctSplitBunch(acctSplitBunch.toString());
|
|
|
+ //添加到汇付临时表,微信
|
|
|
+ THuifuTempOrder tHuifuTempOrder = new THuifuTempOrder();
|
|
|
+ String[] ignoreProperties = {"id"};
|
|
|
+ String id = HuifuUtils.inithuifuTempId();
|
|
|
+ tHuifuTempOrder.setId(id);
|
|
|
+ BeanUtil.copyProperties(order,tHuifuTempOrder,ignoreProperties);
|
|
|
+ huifuTempOrderService.save(tHuifuTempOrder);
|
|
|
+ String result1 = "";
|
|
|
+ if (StrUtil.isNotEmpty(companyType)&&companyType.equals("1")) {
|
|
|
+ result1 = HuifuConstant.SC_JUMP_URL+ "/#/weChatPay?id=" + id;
|
|
|
+ } else {
|
|
|
+ result1 = HuifuConstant.SZ_JUMP_URL+ "/#/weChatPay?id=" + id;
|
|
|
+ }
|
|
|
+ // 支付宝
|
|
|
+ try {
|
|
|
+ result = huifuMchService.uniPay(
|
|
|
+ sn2, amount, productName1, productDesc,
|
|
|
+ notifyUrl, frpCode2, openId, appid, acctSplitBunch, companyType
|
|
|
+ );
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.error("申请支付失败");
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(result)) {
|
|
|
+ return JsonMessage.error("找不到支付图片");
|
|
|
+ }
|
|
|
+ // 汇聚支付支付申请返回支付二维码图片
|
|
|
+ String code1 = "http://sz.sunzee.com.cn/PAY-SERVER/tOrder/aliPay?zfb="+result+"&wx="+result1;
|
|
|
+ String qrcode = toQrcode(code1);
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn", sn1+"-"+sn2);
|
|
|
+ kindData.put("rd_Pic", qrcode);
|
|
|
+ for (String key : productMap.keySet()) {
|
|
|
+ Integer productNum = productMap.get(key);
|
|
|
+ String[] split = key.split("-");
|
|
|
+ BigDecimal unitPrice = new BigDecimal(split[1]);
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetails.setProductNo(productNo);
|
|
|
+ orderDetails.setProductName(split[0]);
|
|
|
+ orderDetails.setPrice(unitPrice);
|
|
|
+ orderDetails.setProductNumber(productNum);
|
|
|
+ orderDetails.setAmount(unitPrice.multiply(new BigDecimal(productNum)));
|
|
|
+ orderDetails.setOrderSn(sn2);
|
|
|
+ orderDetailsService.save(orderDetails);
|
|
|
+ }
|
|
|
+ orderService.save(order2);
|
|
|
+ return JsonMessage.success(kindData.toString());
|
|
|
+ }else{
|
|
|
+ try {
|
|
|
+ result = joinpayMchService.uniPay(
|
|
|
+ orderNo1, amount, productName1, productDesc,
|
|
|
+ commonParameter, returnUrl, notifyUrl, frpCode1,
|
|
|
+ isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
|
|
|
+ buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
|
|
|
+ );
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.error("申请支付失败");
|
|
|
+ }
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ String rc_Result1 = resultJson.getString("rc_Result");
|
|
|
+ String result1 = null;
|
|
|
+ try {
|
|
|
+ result1 = joinpayMchService.uniPay(
|
|
|
+ orderNo2, amount, productName1, productDesc,
|
|
|
+ commonParameter, returnUrl, notifyUrl, frpCode2,
|
|
|
+ isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
|
|
|
+ buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
|
|
|
+ );
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return JsonMessage.error("申请支付失败");
|
|
|
+ }
|
|
|
+ JSONObject resultJson1 = JSONObject.parseObject(result1);
|
|
|
+ String rc_Result2 = resultJson1.getString("rc_Result");
|
|
|
+
|
|
|
+ // 汇聚支付支付申请返回支付二维码图片
|
|
|
+
|
|
|
+ String code1 = "http://app.sunzee.com.cn/"+"/api/order/aliPay.htm?wx="+rc_Result1+"&zfb="+rc_Result2;
|
|
|
+ String rd_Pic = toQrcode(code1);
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn", sn1+"-"+sn2);
|
|
|
+ kindData.put("rd_Pic", rd_Pic);
|
|
|
+ // 添加到订单明细表
|
|
|
+ for (String key : productMap.keySet()) {
|
|
|
+ Integer productNum = productMap.get(key);
|
|
|
+ String[] split = key.split("-");
|
|
|
+ BigDecimal unitPrice = new BigDecimal(split[1]);
|
|
|
+ orderDetails.setProductNo(productNo);
|
|
|
+ orderDetails.setProductName(split[0]);
|
|
|
+ orderDetails.setPrice(unitPrice);
|
|
|
+ orderDetails.setProductNumber(productNum);
|
|
|
+ orderDetails.setAmount(unitPrice.multiply(new BigDecimal(productNum)));
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetails.setOrderSn(sn1);
|
|
|
+ orderDetailsService.save(orderDetails);
|
|
|
+ orderDetails.setId(HuifuUtils.initDetailsId());
|
|
|
+ orderDetails.setOrderSn(sn2);
|
|
|
+ orderDetailsService.save(orderDetails);
|
|
|
+ }
|
|
|
+ orderService.save(order);
|
|
|
+ orderService.save(order2);
|
|
|
+ return JsonMessage.success(kindData.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "汇付:获取code回调跳转到支付页面")
|
|
|
@GetMapping("/callback")
|
|
|
public void oauthCallback(HttpServletRequest request, HttpServletResponse response) throws IOException {
|