java110 vor 5 Jahren
Ursprung
Commit
32dd0a01f9

+ 17 - 7
service-api/src/main/java/com/java110/api/bmo/fee/impl/FeeBMOImpl.java

@@ -151,7 +151,7 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
             endCalender.setTime(endTime);
             BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
             cycles = receivedAmount.divide(feePrice, 2, BigDecimal.ROUND_HALF_EVEN);
-            endCalender = getTargetEndTime(endCalender,cycles.doubleValue());
+            endCalender = getTargetEndTime(endCalender, cycles.doubleValue());
             targetEndTime = endCalender.getTime();
             paramInJson.put("tmpCycles", cycles.doubleValue());
             businessFeeDetail.put("cycles", cycles.doubleValue());
@@ -194,7 +194,7 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
             return endCalender;
         }
 
-        if(cycles >= 1){
+        if (cycles >= 1) {
             endCalender.add(Calendar.MONTH, new Double(Math.floor(cycles)).intValue());
             cycles = cycles - Math.floor(cycles);
         }
@@ -602,6 +602,11 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
      */
     public JSONObject addFee(OwnerCarDto ownerCarDto, JSONObject paramInJson, DataFlowContext dataFlowContext) {
 
+        String time = DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A);
+
+        if (paramInJson.containsKey("startTime")) {
+            time = paramInJson.getString("startTime");
+        }
 
         JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
         business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_INFO);
@@ -613,8 +618,8 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
         businessUnit.put("feeTypeCd", paramInJson.getString("feeTypeCd"));
         businessUnit.put("incomeObjId", paramInJson.getString("storeId"));
         businessUnit.put("amount", "-1.00");
-        businessUnit.put("startTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
-        businessUnit.put("endTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        businessUnit.put("startTime", time);
+        businessUnit.put("endTime", time);
         businessUnit.put("communityId", paramInJson.getString("communityId"));
         businessUnit.put("payerObjId", ownerCarDto.getCarId());
         businessUnit.put("payerObjType", FeeDto.PAYER_OBJ_TYPE_CAR);
@@ -657,7 +662,13 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
      */
     public JSONObject addRoomFee(RoomDto roomDto, JSONObject paramInJson, DataFlowContext dataFlowContext) {
 
+        String time = DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A);
 
+        if(paramInJson.containsKey("feeEndDate")){
+            time = paramInJson.getString("feeEndDate");
+        }else if (paramInJson.containsKey("startTime")) {
+            time = paramInJson.getString("startTime");
+        }
         JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
         business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_INFO);
         business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
@@ -668,9 +679,8 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
         businessUnit.put("feeTypeCd", paramInJson.getString("feeTypeCd"));
         businessUnit.put("incomeObjId", paramInJson.getString("storeId"));
         businessUnit.put("amount", "-1.00");
-        businessUnit.put("startTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
-        businessUnit.put("endTime", paramInJson.containsKey("feeEndDate") ? paramInJson.getString("feeEndDate")
-                : DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        businessUnit.put("startTime", time);
+        businessUnit.put("endTime", time);
         businessUnit.put("communityId", paramInJson.getString("communityId"));
         businessUnit.put("payerObjId", roomDto.getRoomId());
         businessUnit.put("payerObjType", "3333");

+ 1 - 0
service-api/src/main/java/com/java110/api/listener/fee/SaveParkingSpaceCreateFeeListener.java

@@ -72,6 +72,7 @@ public class SaveParkingSpaceCreateFeeListener extends AbstractServiceApiListene
         Assert.hasKeyAndValue(reqJson, "locationObjId", "未包含收费对象");
         Assert.hasKeyAndValue(reqJson, "configId", "未包含收费项目");
         Assert.hasKeyAndValue(reqJson, "storeId", "未包含商户ID");
+        //Assert.hasKeyAndValue(reqJson, "startTime", "未包含费用起始时间");
     }
 
     @Override

+ 1 - 0
service-api/src/main/java/com/java110/api/listener/fee/SaveRoomCreateFeeListener.java

@@ -65,6 +65,7 @@ public class SaveRoomCreateFeeListener extends AbstractServiceApiListener {
         Assert.hasKeyAndValue(reqJson, "locationTypeCd", "未包含收费范围");
         Assert.hasKeyAndValue(reqJson, "locationObjId", "未包含收费对象");
         Assert.hasKeyAndValue(reqJson, "configId", "未包含收费项目");
+        //Assert.hasKeyAndValue(reqJson, "startTime", "未包含收费其实时间");
 //        Assert.hasKeyAndValue(reqJson, "billType", "未包含出账类型");
         Assert.hasKeyAndValue(reqJson, "storeId", "未包含商户ID");
     }

+ 1 - 1
service-front/src/main/java/com/java110/front/controller/goods/GoodsController.java

@@ -41,7 +41,7 @@ import javax.servlet.http.HttpServletRequest;
 public class GoodsController extends BaseController {
 
 
-    //@Autowired
+    @Autowired
     private IGoodsToPaySMO goodsToPaySMOImpl;
 
     /**

+ 141 - 0
service-front/src/main/java/com/java110/front/smo/payment/impl/GoodsToPaySMOImpl.java

@@ -0,0 +1,141 @@
+package com.java110.front.smo.payment.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.context.IPageData;
+import com.java110.core.context.PageData;
+import com.java110.dto.app.AppDto;
+import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.front.properties.WechatAuthProperties;
+import com.java110.front.smo.AppAbstractComponentSMO;
+import com.java110.front.smo.payment.IGoodsToPaySMO;
+import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service("goodsToPaySMOImpl")
+public class GoodsToPaySMOImpl extends AppAbstractComponentSMO implements IGoodsToPaySMO {
+    private static final Logger logger = LoggerFactory.getLogger(AppAbstractComponentSMO.class);
+
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    private RestTemplate outRestTemplate;
+
+
+    @Autowired
+    private WechatAuthProperties wechatAuthProperties;
+
+    @Override
+    public ResponseEntity<String> toPay(IPageData pd) {
+        return super.businessProcess(pd);
+    }
+
+    @Override
+    protected void validate(IPageData pd, JSONObject paramIn) {
+
+        Assert.jsonObjectHaveKey(paramIn, "addressId", "请求报文中未包含地址");
+        Assert.jsonObjectHaveKey(paramIn, "userId", "请求报文中未包含用户ID");
+
+        Assert.hasKey(paramIn, "goodsList", "未包含商品信息");
+
+    }
+
+    @Override
+    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) throws Exception {
+
+        ResponseEntity responseEntity = null;
+
+        SmallWeChatDto smallWeChatDto = null;
+        smallWeChatDto = new SmallWeChatDto();
+        smallWeChatDto.setAppId(wechatAuthProperties.getAppId());
+        smallWeChatDto.setAppSecret(wechatAuthProperties.getSecret());
+        smallWeChatDto.setMchId(wechatAuthProperties.getMchId());
+        smallWeChatDto.setPayPassword(wechatAuthProperties.getKey());
+
+
+        //查询用户ID
+        paramIn.put("userId", pd.getUserId());
+        String url = ServiceConstant.SERVICE_API_URL + "/api/fee.payFeePre";
+        responseEntity = super.callCenterService(restTemplate, pd, paramIn.toJSONString(), url, HttpMethod.POST);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return responseEntity;
+        }
+        JSONObject orderInfo = JSONObject.parseObject(responseEntity.getBody().toString());
+        String orderId = orderInfo.getString("oId");
+        double money = Double.parseDouble(orderInfo.getString("receivableAmount"));
+        String appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA;
+        if (AppDto.WECHAT_OWNER_APP_ID.equals(pd.getAppId())) {
+            appType = OwnerAppUserDto.APP_TYPE_WECHAT;
+        } else if (AppDto.WECHAT_MINA_OWNER_APP_ID.equals(pd.getAppId())) {
+            appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA;
+        } else {
+            appType = OwnerAppUserDto.APP_TYPE_APP;
+        }
+        Map tmpParamIn = new HashMap();
+        tmpParamIn.put("userId", pd.getUserId());
+        tmpParamIn.put("appType", appType);
+        responseEntity = super.getOwnerAppUser(pd, restTemplate, tmpParamIn);
+        logger.debug("查询用户信息返回报文:" + responseEntity);
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("未查询用户信息异常" + tmpParamIn);
+        }
+
+        JSONObject userResult = JSONObject.parseObject(responseEntity.getBody().toString());
+        int total = userResult.getIntValue("total");
+        if (total < 1) {
+            //未查询到用户信息
+            throw new IllegalArgumentException("未查询微信用户");
+        }
+
+        JSONObject realUserInfo = userResult.getJSONArray("data").getJSONObject(0);
+        String openId = realUserInfo.getString("openId");
+
+        Map result = super.java110Payment(outRestTemplate, paramIn.getString("feeName"), paramIn.getString("tradeType"), orderId, money, openId, smallWeChatDto);
+        responseEntity = new ResponseEntity(JSONObject.toJSONString(result), HttpStatus.OK);
+
+        return responseEntity;
+    }
+
+
+    private SmallWeChatDto getSmallWechat(IPageData pd, JSONObject paramIn) {
+
+        ResponseEntity responseEntity = null;
+
+        pd = PageData.newInstance().builder(pd.getUserId(), "", "", pd.getReqData(),
+                "", "", "", "",
+                pd.getAppId());
+        responseEntity = this.callCenterService(restTemplate, pd, "",
+                ServiceConstant.SERVICE_API_URL + "/api/smallWeChat.listSmallWeChats?appId="
+                        + paramIn.getString("appId") + "&page=1&row=1", HttpMethod.GET);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return null;
+        }
+        JSONObject smallWechatObj = JSONObject.parseObject(responseEntity.getBody().toString());
+        JSONArray smallWeChats = smallWechatObj.getJSONArray("smallWeChats");
+
+        if (smallWeChats == null || smallWeChats.size() < 1) {
+            return null;
+        }
+
+        return BeanConvertUtil.covertBean(smallWeChats.get(0), SmallWeChatDto.class);
+    }
+
+
+}