|
@@ -755,6 +755,8 @@ public class OrderController extends BaseController {
|
|
|
kindData.put("rd_Pic",rd_Pic);
|
|
|
return JsonMessage.success(kindData.toString());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
@RequestMapping(value = "/send", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public void send(String client,String sn,String productName){
|
|
@@ -853,6 +855,289 @@ public class OrderController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 被扫支付
|
|
|
+ *
|
|
|
+ * @param clientId 设备client id
|
|
|
+ * @param productName 商品名称
|
|
|
+ * @param frpCode 支付方式 支付宝:ALIPAY_CARD , 微信:WEIXIN_CARD
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/CardPay", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Object CardPay(String clientId, String productName, String frpCode,String authCode) {
|
|
|
+ //解决中文乱码
|
|
|
+// try{
|
|
|
+// if(productName!=null){
|
|
|
+// productName = URLDecoder.decode(productName, "GB2312");
|
|
|
+//// productName = new String(productName.getBytes("ISO8859_1"), "UTF-8");productName = "玫瑰精灵"
|
|
|
+// }
|
|
|
+// }catch (Exception e){
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// productName = "烈焰红唇";
|
|
|
+ Equipment equipment = equipmentService.findByClientId(clientId);
|
|
|
+ if (!frpCode.equals("ALIPAY_CARD") && !frpCode.equals("WEIXIN_CARD")) {
|
|
|
+ return JsonMessage.error("参数错误");
|
|
|
+ }
|
|
|
+ if(equipment==null){
|
|
|
+ return JsonMessage.error("找不到设备");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long equipmentId = equipment.getId();
|
|
|
+
|
|
|
+ Product product = productService.getByProductName(equipmentId, productName);
|
|
|
+
|
|
|
+ if (product == null) {
|
|
|
+ return JsonMessage.error("找不到商品");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal price = product.getRmbPrice();
|
|
|
+ if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
+ return JsonMessage.error("商品价格异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ String sn = orderService.initSn(equipmentId);
|
|
|
+
|
|
|
+ Proportion proportion = proportionService.getUniqueness(equipment.getAdminId());
|
|
|
+ if (proportion == null) {
|
|
|
+ return JsonMessage.error("设备商家未完成分销设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ Admin admin = adminService.find(equipment.getAdminId());
|
|
|
+ if (admin == null) {
|
|
|
+ return JsonMessage.error("找不到设备商家");
|
|
|
+ }
|
|
|
+
|
|
|
+ Proportion.Type type = proportion.getType();
|
|
|
+ JSONArray altInfo = new JSONArray();
|
|
|
+ JSONArray altNewInfo = new JSONArray();
|
|
|
+
|
|
|
+ BigDecimal adminProportion = null, agencyProportion = null, merchantProportion = null, personageProportion = null;
|
|
|
+ Long agencyId = admin.getAgencyId();
|
|
|
+ Long merchantId = admin.getMerchantId();
|
|
|
+ Long personageId = admin.getPersonageId();
|
|
|
+ Order.Type orderType = null;
|
|
|
+
|
|
|
+ if (type == null) {
|
|
|
+ return JsonMessage.error("设备商家未完成分销设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal agencyAmount = null;
|
|
|
+ BigDecimal merchantAmount = null;
|
|
|
+ BigDecimal personageAmount = null;
|
|
|
+
|
|
|
+ Mch agencyMch = null;
|
|
|
+ Mch merchantMch = null;
|
|
|
+ Mch personageMch = null;
|
|
|
+
|
|
|
+ JSONObject agencyJson = null;
|
|
|
+ JSONObject merchantJson = null;
|
|
|
+ JSONObject personageJson = null;
|
|
|
+
|
|
|
+ // 砍掉千6手续费
|
|
|
+// BigDecimal cutPrice = price.multiply(new BigDecimal(99.4)).divide(new BigDecimal(100));
|
|
|
+ //取消平台扣手续费
|
|
|
+ BigDecimal cutPrice = price.multiply(new BigDecimal(100)).divide(new BigDecimal(100));
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+
|
|
|
+ case agency:
|
|
|
+
|
|
|
+ if (admin.getType() != Admin.Type.agency) {
|
|
|
+ return JsonMessage.error("设备商家类型错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ agencyMch = mchService.getUniqueness(admin.getAgencyId());
|
|
|
+ if (agencyMch == null || StringUtils.isBlank(agencyMch.getOrder_status())) {
|
|
|
+ return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ }
|
|
|
+
|
|
|
+ agencyProportion = proportion.getAgencyProportion();
|
|
|
+ adminProportion = proportion.getAdminProportion();
|
|
|
+ orderType = Order.Type.agency;
|
|
|
+
|
|
|
+ // 代理分销获得利润
|
|
|
+ agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+
|
|
|
+ agencyJson = new JSONObject();
|
|
|
+ agencyJson.put("altMchNo", agencyMch.getAlt_mch_no());
|
|
|
+ agencyJson.put("altAmount", agencyAmount.toString());
|
|
|
+ agencyJson.put("isGuar", "12");
|
|
|
+ altInfo.add(agencyJson);
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case merchant:
|
|
|
+
|
|
|
+ if (admin.getType() != Admin.Type.merchant) {
|
|
|
+ return JsonMessage.error("设备商家类型错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ agencyMch = mchService.getUniqueness(admin.getAgencyId());
|
|
|
+ merchantMch = mchService.getUniqueness(admin.getMerchantId());
|
|
|
+
|
|
|
+ if (agencyMch == null || StringUtils.isBlank(agencyMch.getOrder_status())) {
|
|
|
+ return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (merchantMch == null || StringUtils.isBlank(merchantMch.getOrder_status())) {
|
|
|
+ return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ }
|
|
|
+
|
|
|
+ agencyProportion = proportion.getAgencyProportion();
|
|
|
+ adminProportion = proportion.getAdminProportion();
|
|
|
+ merchantProportion = proportion.getMerchantProportion();
|
|
|
+ orderType = Order.Type.merchant;
|
|
|
+
|
|
|
+ // 代理分销获得利润
|
|
|
+ agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+
|
|
|
+ // 经销商分销获得利润
|
|
|
+ merchantAmount = cutPrice.multiply(merchantProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+
|
|
|
+ agencyJson = new JSONObject();
|
|
|
+ agencyJson.put("altMchNo", agencyMch.getAlt_mch_no());
|
|
|
+ agencyJson.put("altAmount", agencyAmount.toString());
|
|
|
+ agencyJson.put("isGuar", "12");
|
|
|
+ altInfo.add(agencyJson);
|
|
|
+
|
|
|
+ merchantJson = new JSONObject();
|
|
|
+ merchantJson.put("altMchNo", merchantMch.getAlt_mch_no());
|
|
|
+ merchantJson.put("altAmount", merchantAmount.toString());
|
|
|
+ merchantJson.put("isGuar", "12");
|
|
|
+ altInfo.add(merchantJson);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case personage:
|
|
|
+
|
|
|
+ if (admin.getType() != Admin.Type.personage) {
|
|
|
+ return JsonMessage.error("设备商家类型错误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ agencyMch = mchService.getUniqueness(admin.getAgencyId());
|
|
|
+ merchantMch = mchService.getUniqueness(admin.getMerchantId());
|
|
|
+ personageMch = mchService.getUniqueness(admin.getPersonageId());
|
|
|
+
|
|
|
+
|
|
|
+ if (agencyMch == null || StringUtils.isBlank(agencyMch.getOrder_status())) {
|
|
|
+ return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (merchantMch == null || StringUtils.isBlank(merchantMch.getOrder_status())) {
|
|
|
+ return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (personageMch == null || StringUtils.isBlank(personageMch.getOrder_status())) {
|
|
|
+ return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ }
|
|
|
+
|
|
|
+ agencyProportion = proportion.getAgencyProportion();
|
|
|
+ adminProportion = proportion.getAdminProportion();
|
|
|
+ merchantProportion = proportion.getMerchantProportion();
|
|
|
+ personageProportion = proportion.getPersonageProportion();
|
|
|
+
|
|
|
+ orderType = Order.Type.personage;
|
|
|
+
|
|
|
+ // 代理分销获得利润
|
|
|
+ agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+
|
|
|
+ // 经销商分销获得利润
|
|
|
+ merchantAmount = cutPrice.multiply(merchantProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+
|
|
|
+ // 经销商分销获得利润
|
|
|
+ personageAmount = cutPrice.multiply(personageProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+
|
|
|
+ agencyJson = new JSONObject();
|
|
|
+ agencyJson.put("altMchNo", agencyMch.getAlt_mch_no());
|
|
|
+ agencyJson.put("altAmount", agencyAmount.toString());
|
|
|
+ agencyJson.put("isGuar", "12");
|
|
|
+ altInfo.add(agencyJson);
|
|
|
+
|
|
|
+ merchantJson = new JSONObject();
|
|
|
+ merchantJson.put("altMchNo", merchantMch.getAlt_mch_no());
|
|
|
+ merchantJson.put("altAmount", merchantAmount.toString());
|
|
|
+ merchantJson.put("isGuar", "12");
|
|
|
+ altInfo.add(merchantJson);
|
|
|
+
|
|
|
+ personageJson = new JSONObject();
|
|
|
+ personageJson.put("altMchNo", personageMch.getAlt_mch_no());
|
|
|
+ personageJson.put("altAmount", personageAmount.toString());
|
|
|
+ personageJson.put("isGuar", "12");
|
|
|
+ altInfo.add(personageJson);
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String orderNo = sn;
|
|
|
+ BigDecimal amount = price;
|
|
|
+ String productDesc = "";
|
|
|
+ String commonParameter = "";
|
|
|
+ String returnUrl = null;
|
|
|
+ String notifyUrl = JoinpayConstant.Card_Notify_Url;
|
|
|
+ String isShowPic = "";
|
|
|
+ String openId = null;
|
|
|
+ String AuthCode = authCode;
|
|
|
+ String appid = null;
|
|
|
+ String transactionModel = null;
|
|
|
+ String tradeMerchantNo = null;
|
|
|
+ String buyerId = null;
|
|
|
+ String isAlt = "1";
|
|
|
+ String altType = "11";
|
|
|
+ String altUrl = null;
|
|
|
+ BigDecimal marketingAmount = null;
|
|
|
+
|
|
|
+ Order order = new Order(sn, product.getId(), productName, price, equipment.getClientId(), equipmentId,
|
|
|
+ orderType, admin.getId(), agencyId, merchantId, personageId,
|
|
|
+ frpCode, altInfo.toString(), adminProportion, agencyProportion, merchantProportion, personageProportion, Order.Status.unpay);
|
|
|
+
|
|
|
+ orderService.create(order);
|
|
|
+
|
|
|
+ Iterator<Object> iterator = altInfo.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ JSONObject jsonObject = (JSONObject) iterator.next();
|
|
|
+ String altAmount = jsonObject.getString("altAmount");
|
|
|
+ if (altAmount.equals("0.00")) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String client6= clientId.substring(clientId.length()-6,clientId.length());
|
|
|
+ productName=productName+"-"+equipment.getName()+"-"+client6;
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ result = tradeService.uniPay(
|
|
|
+
|
|
|
+ orderNo, amount, productName, productDesc,
|
|
|
+ commonParameter, returnUrl, notifyUrl, frpCode,
|
|
|
+ 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 rd_Pic = resultJson.getString("rd_Pic");
|
|
|
+// Map<String,String> map2 = new HashMap<>();
|
|
|
+// map2.put("sn",sn);
|
|
|
+// map2.put("rd_Pic",rd_Pic);
|
|
|
+ if (resultJson == null || StringUtils.isBlank(rd_Pic)) {
|
|
|
+ return JsonMessage.error("找不到支付图片");
|
|
|
+ }
|
|
|
+// send(clientId,sn,productName);
|
|
|
+// return JsonMessage.success(rd_Pic);
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn" , sn);
|
|
|
+ kindData.put("rd_Pic",rd_Pic);
|
|
|
+ return JsonMessage.success(kindData.toString());
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 清洗机器人支付成功回调
|
|
|
*
|
|
|
* @return
|