|
@@ -10,25 +10,16 @@ import com.szwl.feign.bean.PayFeign;
|
|
|
import com.szwl.model.bo.JoinpayConstant;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
-import com.szwl.model.entity.TAdmin;
|
|
|
-import com.szwl.model.entity.TEquipment;
|
|
|
-import com.szwl.model.entity.TOrder;
|
|
|
-import com.szwl.model.entity.TShandeMch;
|
|
|
+import com.szwl.model.entity.*;
|
|
|
import com.szwl.model.utils.Constant;
|
|
|
-import com.szwl.service.TAdminService;
|
|
|
-import com.szwl.service.TEquipmentService;
|
|
|
-import com.szwl.service.TOrderService;
|
|
|
-import com.szwl.service.TShandeMchService;
|
|
|
+import com.szwl.service.*;
|
|
|
import com.szwl.service.es.EsTOrderService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -58,6 +49,10 @@ public class TOrderController {
|
|
|
TShandeMchService tShandeMchService;
|
|
|
@Autowired
|
|
|
EsTOrderService esTOrderService;
|
|
|
+ @Autowired
|
|
|
+ TPriceService priceService;
|
|
|
+ @Autowired
|
|
|
+ TJoinpayMchService joinpayMchService;
|
|
|
/**
|
|
|
* 退款
|
|
|
* @param
|
|
@@ -312,5 +307,89 @@ public class TOrderController {
|
|
|
.setData("申请退款已成功")
|
|
|
.setMessage("申请退款已成功"));
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加优惠码")
|
|
|
+ @GetMapping("/equipmentPay")
|
|
|
+ public ResponseModel<?> equipmentPay(Double number, Long equipmentId, String frpCode) {
|
|
|
+ TEquipment equipment = tEquipmentService.getById(equipmentId);
|
|
|
+ if (!frpCode.equals("ALIPAY_NATIVE") && !frpCode.equals("WEIXIN_NATIVE")) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ if (equipment == null) {
|
|
|
+ return R.fail("找不到设备");
|
|
|
+ }
|
|
|
+ TAdmin admin = tAdminService.getById(equipment.getAdminId());
|
|
|
+ Double money = null;
|
|
|
+ LambdaQueryWrapper<TPrice> query1 = Wrappers.lambdaQuery();
|
|
|
+ query1.eq(TPrice::getName,"MG280");
|
|
|
+ List<TPrice> prices = priceService.list(query1);
|
|
|
+ for(TPrice price:prices){
|
|
|
+ if(price.getName().equals("MG280")){
|
|
|
+ money = price.getPrice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BigDecimal price = null;
|
|
|
+ double pri = money * number;
|
|
|
+ price = BigDecimal.valueOf(pri);
|
|
|
+
|
|
|
+ String sn = orderService.initSn(equipmentId);
|
|
|
+ String orderNo = sn;
|
|
|
+ String productName = "280充值";
|
|
|
+ BigDecimal cutPrice = price.multiply(new BigDecimal(100)).divide(new BigDecimal(100));
|
|
|
+ BigDecimal amount = cutPrice;
|
|
|
+ String productDesc = "";
|
|
|
+ String commonParameter = "";
|
|
|
+ String returnUrl = null;
|
|
|
+ String notifyUrl = JoinpayConstant.Notify_Url_PromoCode;
|
|
|
+ String isShowPic = "1";
|
|
|
+ String openId = null;
|
|
|
+ String authCode = null;
|
|
|
+ String appid = null;
|
|
|
+ String transactionModel = null;
|
|
|
+ String tradeMerchantNo = null;
|
|
|
+ String buyerId = null;
|
|
|
+ String isAlt = "0";
|
|
|
+ String altType = null;
|
|
|
+ String altUrl = null;
|
|
|
+ BigDecimal marketingAmount = null;
|
|
|
+// frpCode = "WEIXIN_NATIVE";
|
|
|
+ TOrder order1 = new TOrder();
|
|
|
+ order1.setSn(sn);
|
|
|
+ order1.setType(0);
|
|
|
+ order1.setAdminId(admin.getId());
|
|
|
+ order1.setProductName(productName);
|
|
|
+ order1.setPrice(price);
|
|
|
+ order1.setEquipmentId(equipmentId);
|
|
|
+ order1.setClientId(equipment.getClientId());
|
|
|
+ order1.setStatus(0);
|
|
|
+ order1.setFrpCode(frpCode);
|
|
|
+ order1.setCreateDate(new Date());
|
|
|
+ order1.setModifyDate(new Date());
|
|
|
+ payFeign.addOrder(order1);
|
|
|
+ JSONArray altInfo = new JSONArray();
|
|
|
+ String result = null;
|
|
|
+ try {
|
|
|
+ result = joinpayMchService.uniPay(
|
|
|
+ orderNo, amount, productName, productDesc,
|
|
|
+ commonParameter, returnUrl, notifyUrl, frpCode,
|
|
|
+ isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
|
|
|
+ buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
|
|
|
+ );
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.fail("申请支付失败");
|
|
|
+ }
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ // 汇聚支付支付申请返回支付二维码图片
|
|
|
+ String rd_Pic = resultJson.getString("rd_Pic");
|
|
|
+ if (resultJson == null || StringUtils.isBlank(rd_Pic)) {
|
|
|
+ return R.fail("找不到支付图片");
|
|
|
+ }
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
+ kindData.put("sn", sn);
|
|
|
+ kindData.put("price", price);
|
|
|
+ kindData.put("image", rd_Pic);
|
|
|
+ return R.ok(kindData);
|
|
|
+ }
|
|
|
}
|
|
|
|