Quellcode durchsuchen

优化 商品支付流程

java110 vor 5 Jahren
Ursprung
Commit
55bf4ad6f5

+ 1 - 0
java110-bean/src/main/java/com/java110/dto/fee/FeeConfigDto.java

@@ -29,6 +29,7 @@ public class FeeConfigDto extends PageDto implements Serializable {
     public static final String FEE_TYPE_CD_SYSTEM = "888800010000";//系统
 
     public static final String CONFIG_ID_RENTING = "920000000000000000";//租赁费用项
+    public static final String CONFIG_ID_GOODS = "930000000000000000";//商品费用项
 
 
 

+ 2 - 0
java110-bean/src/main/java/com/java110/dto/groupBuy/GroupBuyDto.java

@@ -15,6 +15,8 @@ import java.util.Date;
  **/
 public class GroupBuyDto extends PageDto implements Serializable {
 
+    public static final String STATE_SUCCESS = "2002";
+
     private String specId;
     private String buyCount;
     private String amount;

+ 1 - 0
java110-bean/src/main/java/com/java110/dto/storeCart/StoreCartDto.java

@@ -16,6 +16,7 @@ import java.util.Date;
 public class StoreCartDto extends PageDto implements Serializable {
 
     public static final String STATE_NO_BUY = "1001"; // 未购买
+    public static final String STATE_FINISH_BUY = "2002"; // 未购买完成
 
     private String valueId;
     private String productId;

+ 1 - 1
java110-bean/src/main/java/com/java110/dto/storeOrderCart/StoreOrderCartDto.java

@@ -16,7 +16,7 @@ import java.util.Date;
 public class StoreOrderCartDto extends PageDto implements Serializable {
 
     public static final String STATE_WAIT_BUY = "1001";//未购买
-    public static final String STATE_FINISH_BUY = "2002";//已支付
+    public static final String STATE_WAIT_SEND = "2002";//待发货
 
     private String valueId;
     private String productId;

+ 4 - 6
java110-db/src/main/resources/mapper/goods/GroupBuyProductSpecServiceDaoImplMapper.xml

@@ -65,9 +65,6 @@
     <!-- 修改拼团产品规格信息 add by wuxw 2018-07-03 -->
     <update id="updateGroupBuyProductSpecInfo" parameterType="Map">
         update group_buy_product_spec t set t.status_cd = #{statusCd}
-        <if test="newBId != null and newBId != ''">
-            ,t.b_id = #{newBId}
-        </if>
         <if test="groupSales !=null and groupSales != ''">
             , t.group_sales= #{groupSales}
         </if>
@@ -77,9 +74,7 @@
         <if test="defaultShow !=null and defaultShow != ''">
             , t.default_show= #{defaultShow}
         </if>
-        <if test="storeId !=null and storeId != ''">
-            , t.store_id= #{storeId}
-        </if>
+
         <if test="groupStock !=null and groupStock != ''">
             , t.group_stock= #{groupStock}
         </if>
@@ -93,6 +88,9 @@
         <if test="productId !=null and productId != ''">
             and t.product_id= #{productId}
         </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
+        </if>
 
     </update>
 

+ 5 - 6
java110-db/src/main/resources/mapper/goods/ProductSpecValueServiceDaoImplMapper.xml

@@ -92,9 +92,7 @@
     <!-- 修改产品规格值信息 add by wuxw 2018-07-03 -->
     <update id="updateProductSpecValueInfo" parameterType="Map">
         update product_spec_value t set t.status_cd = #{statusCd}
-        <if test="newBId != null and newBId != ''">
-            ,t.b_id = #{newBId}
-        </if>
+
         <if test="specId !=null and specId != ''">
             , t.spec_id= #{specId}
         </if>
@@ -111,9 +109,7 @@
         <if test="vipPrice !=null and vipPrice != ''">
             , t.vip_price= #{vipPrice}
         </if>
-        <if test="storeId !=null and storeId != ''">
-            , t.store_id= #{storeId}
-        </if>
+
         <if test="stock !=null and stock != ''">
             , t.stock= #{stock}
         </if>
@@ -130,6 +126,9 @@
         <if test="productId !=null and productId != ''">
             and t.product_id= #{productId}
         </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
+        </if>
 
     </update>
 

+ 5 - 6
java110-db/src/main/resources/mapper/goods/StoreCartServiceDaoImplMapper.xml

@@ -59,9 +59,7 @@
     <!-- 修改购物车信息 add by wuxw 2018-07-03 -->
     <update id="updateStoreCartInfo" parameterType="Map">
         update store_cart t set t.status_cd = #{statusCd}
-        <if test="newBId != null and newBId != ''">
-            ,t.b_id = #{newBId}
-        </if>
+
         <if test="valueId !=null and valueId != ''">
             , t.value_id= #{valueId}
         </if>
@@ -74,9 +72,7 @@
         <if test="state !=null and state != ''">
             , t.state= #{state}
         </if>
-        <if test="storeId !=null and storeId != ''">
-            , t.store_id= #{storeId}
-        </if>
+
         <if test="cartNum !=null and cartNum != ''">
             , t.cart_num= #{cartNum}
         </if>
@@ -84,6 +80,9 @@
         <if test="cartId !=null and cartId != ''">
             and t.cart_id= #{cartId}
         </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
+        </if>
 
     </update>
 

+ 5 - 6
java110-db/src/main/resources/mapper/goods/StoreOrderCartServiceDaoImplMapper.xml

@@ -73,18 +73,14 @@
     <!-- 修改订单购物车信息 add by wuxw 2018-07-03 -->
     <update id="updateStoreOrderCartInfo" parameterType="Map">
         update store_order_cart t set t.status_cd = #{statusCd}
-        <if test="newBId != null and newBId != ''">
-            ,t.b_id = #{newBId}
-        </if>
+
         <if test="valueId !=null and valueId != ''">
             , t.value_id= #{valueId}
         </if>
         <if test="productId !=null and productId != ''">
             , t.product_id= #{productId}
         </if>
-        <if test="orderId !=null and orderId != ''">
-            , t.order_id= #{orderId}
-        </if>
+
         <if test="remark !=null and remark != ''">
             , t.remark= #{remark}
         </if>
@@ -113,6 +109,9 @@
         <if test="cartId !=null and cartId != ''">
             and t.cart_id= #{cartId}
         </if>
+        <if test="orderId !=null and orderId != ''">
+            and t.order_id= #{orderId}
+        </if>
 
     </update>
 

+ 1 - 3
java110-db/src/main/resources/mapper/goods/StoreOrderServiceDaoImplMapper.xml

@@ -67,9 +67,7 @@
     <!-- 修改购物车信息 add by wuxw 2018-07-03 -->
     <update id="updateStoreOrderInfo" parameterType="Map">
         update store_order t set t.status_cd = #{statusCd}
-        <if test="newBId != null and newBId != ''">
-            ,t.b_id = #{newBId}
-        </if>
+
         <if test="personName !=null and personName != ''">
             , t.person_name= #{personName}
         </if>

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

@@ -15,12 +15,16 @@
  */
 package com.java110.front.controller.goods;
 
+import com.java110.core.base.AppBase;
 import com.java110.core.base.controller.BaseController;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
+import com.java110.front.smo.payment.IGoodsToNotifySMO;
 import com.java110.front.smo.payment.IGoodsToPaySMO;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -40,10 +44,14 @@ import javax.servlet.http.HttpServletRequest;
 @RequestMapping(path = "/goods")
 public class GoodsController extends BaseController {
 
+    private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);
 
     @Autowired
     private IGoodsToPaySMO goodsToPaySMOImpl;
 
+    @Autowired
+    private IGoodsToNotifySMO goodsToNotifySMOImpl;
+
     /**
      * <p>统一下单入口</p>
      *
@@ -63,4 +71,20 @@ public class GoodsController extends BaseController {
                 appId);
         return goodsToPaySMOImpl.toPay(newPd);
     }
+
+    /**
+     * <p>支付回调Api</p>
+     * /goods/notify
+     * @param request
+     * @throws Exception
+     */
+    @RequestMapping(path = "/notify", method = RequestMethod.POST)
+    public ResponseEntity<String> notify(@RequestBody String postInfo, HttpServletRequest request) {
+
+        logger.debug("微信支付回调报文" + postInfo);
+
+        return goodsToNotifySMOImpl.toNotify(postInfo, request);
+
+
+    }
 }

+ 9 - 0
service-front/src/main/java/com/java110/front/properties/WechatAuthProperties.java

@@ -29,6 +29,7 @@ public class WechatAuthProperties {
     private String wxPayUnifiedOrder;
     private String wxNotifyUrl;
     private String rentingNotifyUrl;
+    private String goodsNotifyUrl;
     private String oweFeeNotifyUrl;
 
     private String wechatAppId;//微信公众号ID
@@ -139,4 +140,12 @@ public class WechatAuthProperties {
     public void setOweFeeNotifyUrl(String oweFeeNotifyUrl) {
         this.oweFeeNotifyUrl = oweFeeNotifyUrl;
     }
+
+    public String getGoodsNotifyUrl() {
+        return goodsNotifyUrl;
+    }
+
+    public void setGoodsNotifyUrl(String goodsNotifyUrl) {
+        this.goodsNotifyUrl = goodsNotifyUrl;
+    }
 }

+ 18 - 0
service-front/src/main/java/com/java110/front/smo/payment/IGoodsToNotifySMO.java

@@ -0,0 +1,18 @@
+package com.java110.front.smo.payment;
+
+import org.springframework.http.ResponseEntity;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 商品通知 支付完成
+ */
+public interface IGoodsToNotifySMO {
+
+    /**
+     * 支付完成
+     * @param request
+     * @return
+     */
+    public ResponseEntity<String> toNotify(String param,HttpServletRequest request);
+}

+ 197 - 0
service-front/src/main/java/com/java110/front/smo/payment/impl/GoodsToNotifySMOImpl.java

@@ -0,0 +1,197 @@
+package com.java110.front.smo.payment.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.factory.WechatFactory;
+import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.front.properties.WechatAuthProperties;
+import com.java110.front.smo.AppAbstractComponentSMO;
+import com.java110.front.smo.payment.IGoodsToNotifySMO;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.constant.ServiceCodeConstant;
+import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.PayUtil;
+import com.java110.vo.ResultVo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+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.HttpStatusCodeException;
+import org.springframework.web.client.RestTemplate;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.UUID;
+
+@Service("goodsToNotifySMOImpl")
+public class GoodsToNotifySMOImpl implements IGoodsToNotifySMO {
+    private static final Logger logger = LoggerFactory.getLogger(AppAbstractComponentSMO.class);
+
+    private static final String APP_ID = "992020011134400001";
+
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    private WechatAuthProperties wechatAuthProperties;
+
+    @Override
+    public ResponseEntity<String> toNotify(String param, HttpServletRequest request) {
+        String resXml = "";
+        ResponseEntity responseEntity = null;
+        try {
+
+            Map<String, Object> map = PayUtil.getMapFromXML(param);
+            logger.info("【小程序支付回调】 回调数据: \n" + map);
+            String returnCode = (String) map.get("return_code");
+            if ("SUCCESS".equalsIgnoreCase(returnCode)) {
+                String returnmsg = (String) map.get("result_code");
+                if ("SUCCESS".equals(returnmsg)) {
+                    //更新数据
+                    int result = confirmPayFee(map);
+                    if (result > 0) {
+                        //支付成功
+                        resXml = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>"
+                                + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml>";
+                    }
+                } else {
+                    resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
+                            + "<return_msg><![CDATA[报文为空]></return_msg>" + "</xml>";
+                    logger.info("支付失败:" + resXml);
+                }
+            } else {
+                resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
+                        + "<return_msg><![CDATA[报文为空]></return_msg>" + "</xml>";
+                logger.info("【订单支付失败】");
+            }
+        } catch (Exception e) {
+            logger.error("通知失败", e);
+            resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>"
+                    + "<return_msg><![CDATA[鉴权失败]></return_msg>" + "</xml>";
+        }
+
+        logger.info("【小程序支付回调响应】 响应内容:\n" + resXml);
+        return new ResponseEntity<String>(resXml, HttpStatus.OK);
+    }
+
+    public int confirmPayFee(Map<String, Object> map) {
+        String wId = map.get("wId").toString();
+        wId = wId.replace(" ", "+");
+        SortedMap<String, String> paramMap = new TreeMap<String, String>();
+        ResponseEntity<String> responseEntity = null;
+        for (String key : map.keySet()) {
+            if ("wId".equals(key)) {
+                continue;
+            }
+            paramMap.put(key, map.get(key).toString());
+        }
+        String appId = WechatFactory.getAppId(wId);
+        SmallWeChatDto smallWeChatDto = new SmallWeChatDto();
+        smallWeChatDto.setAppId(wechatAuthProperties.getAppId());
+        smallWeChatDto.setAppSecret(wechatAuthProperties.getSecret());
+        smallWeChatDto.setMchId(wechatAuthProperties.getMchId());
+        smallWeChatDto.setPayPassword(wechatAuthProperties.getKey());
+
+        String sign = PayUtil.createSign(paramMap, smallWeChatDto.getPayPassword());
+
+        if (!sign.equals(map.get("sign"))) {
+            throw new IllegalArgumentException("鉴权失败");
+        }
+
+        String outTradeNo = map.get("out_trade_no").toString();
+        String openId = "";
+        String paySwitch = MappingCache.getValue(AppAbstractComponentSMO.DOMAIN_WECHAT_PAY, AppAbstractComponentSMO.WECHAT_SERVICE_PAY_SWITCH);
+        if (AppAbstractComponentSMO.WECHAT_SERVICE_PAY_SWITCH_ON.equals(paySwitch)) {
+            openId = map.get("sub_openid").toString();
+        } else {
+            openId = map.get("openid").toString();
+        }
+
+        responseEntity = getUserInfoByOpenId(restTemplate, openId);
+
+        logger.debug("查询用户信息返回报文:" + responseEntity);
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            throw new IllegalArgumentException("根绝openId 查询用户信息异常" + openId);
+        }
+
+        JSONObject userResult = JSONObject.parseObject(responseEntity.getBody());
+        JSONObject realUserInfo = userResult.getJSONArray("data").getJSONObject(0);
+        String useId = realUserInfo.getString("userId");
+
+        //查询用户ID
+        JSONObject paramIn = new JSONObject();
+        paramIn.put("orderId", outTradeNo);
+        String url = ServiceConstant.SERVICE_API_URL + "/app/storeOrder/updateStoreOrder";
+        responseEntity = this.callCenterService(restTemplate, useId, paramIn.toJSONString(), url, HttpMethod.POST);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return 0;
+        }
+
+        JSONObject data = JSONObject.parseObject(responseEntity.getBody());
+
+        if (ResultVo.CODE_OK != data.getInteger("code")) {
+            return 0;
+        }
+        return 1;
+    }
+
+    /**
+     * 获取用户信息
+     *
+     * @param restTemplate
+     * @return
+     */
+    protected ResponseEntity<String> getUserInfoByOpenId(RestTemplate restTemplate, String openId) {
+        //Assert.hasLength(pd.getUserId(), "用户未登录请先登录");
+        ResponseEntity<String> responseEntity = null;
+        responseEntity = this.callCenterService(restTemplate, "-1", "",
+                ServiceConstant.SERVICE_API_URL + "/api/" + ServiceCodeConstant.LIST_APPUSERBINDINGOWNERS + "?openId=" + openId + "&page=1&row=1", HttpMethod.GET);
+        // 过滤返回报文中的字段,只返回name字段
+        //{"address":"","orderTypeCd":"Q","serviceCode":"","responseTime":"20190401194712","sex":"","localtionCd":"","userId":"302019033054910001","levelCd":"00","transactionId":"-1","dataFlowId":"-1","response":{"code":"0000","message":"成功"},"name":"996icu","tel":"18909780341","bId":"-1","businessType":"","email":""}
+
+        return responseEntity;
+
+    }
+
+    /**
+     * 调用中心服务
+     *
+     * @return
+     */
+    protected ResponseEntity<String> callCenterService(RestTemplate restTemplate, String userId, String param, String url, HttpMethod httpMethod) {
+
+        ResponseEntity<String> responseEntity = null;
+        HttpHeaders header = new HttpHeaders();
+        header.add(CommonConstant.HTTP_APP_ID.toLowerCase(), APP_ID);
+        header.add(CommonConstant.HTTP_USER_ID.toLowerCase(), userId);
+        header.add(CommonConstant.HTTP_TRANSACTION_ID.toLowerCase(), UUID.randomUUID().toString());
+        header.add(CommonConstant.HTTP_REQ_TIME.toLowerCase(), DateUtil.getDefaultFormateTimeString(new Date()));
+        header.add(CommonConstant.HTTP_SIGN.toLowerCase(), "");
+        HttpEntity<String> httpEntity = new HttpEntity<String>(param, header);
+        //logger.debug("请求中心服务信息,{}", httpEntity);
+        try {
+            responseEntity = restTemplate.exchange(url, httpMethod, httpEntity, String.class);
+        } catch (HttpStatusCodeException e) { //这里spring 框架 在4XX 或 5XX 时抛出 HttpServerErrorException 异常,需要重新封装一下
+            responseEntity = new ResponseEntity<String>(e.getResponseBodyAsString(), e.getStatusCode());
+        } catch (Exception e) {
+            responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        } finally {
+            logger.debug("请求地址为,{} 请求中心服务信息,{},中心服务返回信息,{}", url, httpEntity, responseEntity);
+            return responseEntity;
+        }
+
+    }
+
+
+}

+ 1 - 0
service-front/src/main/resources/wechatAuth.properties

@@ -7,6 +7,7 @@ java110.auth.wechat.mchId=mchId
 java110.auth.wechat.wxPayUnifiedOrder=https://api.mch.weixin.qq.com/pay/unifiedorder
 java110.auth.wechat.wxNotifyUrl=https://app.demo.winqi.cn/app/payment/notify
 java110.auth.wechat.rentingNotifyUrl=https://app.demo.winqi.cn/app/payment/rentingNotify
+java110.auth.wechat.goodsNotifyUrl=https://app.demo.winqi.cn/app/goods/notify
 java110.auth.wechat.oweFeeNotifyUrl=https://app.demo.winqi.cn/app/payment/oweFeeNotify
 
 # ¹«ÖÚºÅÐÅÏ¢

+ 1 - 6
service-goods/src/main/java/com/java110/goods/api/StoreOrderApi.java

@@ -96,12 +96,7 @@ public class StoreOrderApi {
     @RequestMapping(value = "/updateStoreOrder", method = RequestMethod.POST)
     public ResponseEntity<String> updateStoreOrder(@RequestBody JSONObject reqJson) {
 
-        Assert.hasKeyAndValue(reqJson, "personId", "请求报文中未包含personId");
-        Assert.hasKeyAndValue(reqJson, "personName", "请求报文中未包含personName");
-        Assert.hasKeyAndValue(reqJson, "totalPrice", "请求报文中未包含totalPrice");
-        Assert.hasKeyAndValue(reqJson, "payPrice", "请求报文中未包含payPrice");
-        Assert.hasKeyAndValue(reqJson, "orderId", "orderId不能为空");
-
+        Assert.hasKeyAndValue(reqJson, "orderId", "请求报文中未包含orderId");
 
         StoreOrderPo storeOrderPo = BeanConvertUtil.covertBean(reqJson, StoreOrderPo.class);
         return updateStoreOrderBMOImpl.update(storeOrderPo);

+ 200 - 3
service-goods/src/main/java/com/java110/goods/bmo/storeOrder/impl/UpdateStoreOrderBMOImpl.java

@@ -1,20 +1,67 @@
 package com.java110.goods.bmo.storeOrder.impl;
 
 import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.fee.FeeConfigDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.groupBuy.GroupBuyDto;
+import com.java110.dto.groupBuyProduct.GroupBuyProductDto;
+import com.java110.dto.productSpecValue.ProductSpecValueDto;
+import com.java110.dto.storeCart.StoreCartDto;
+import com.java110.dto.storeOrder.StoreOrderDto;
+import com.java110.dto.storeOrderCart.StoreOrderCartDto;
 import com.java110.goods.bmo.storeOrder.IUpdateStoreOrderBMO;
+import com.java110.intf.IStoreOrderCartInnerServiceSMO;
 import com.java110.intf.IStoreOrderInnerServiceSMO;
+import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.goods.IGroupBuyInnerServiceSMO;
+import com.java110.intf.goods.IGroupBuyProductInnerServiceSMO;
+import com.java110.intf.goods.IProductSpecValueInnerServiceSMO;
+import com.java110.intf.goods.IStoreCartInnerServiceSMO;
+import com.java110.po.fee.PayFeeDetailPo;
+import com.java110.po.fee.PayFeePo;
+import com.java110.po.groupBuy.GroupBuyPo;
+import com.java110.po.storeCart.StoreCartPo;
 import com.java110.po.storeOrder.StoreOrderPo;
+import com.java110.po.storeOrderCart.StoreOrderCartPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 @Service("updateStoreOrderBMOImpl")
 public class UpdateStoreOrderBMOImpl implements IUpdateStoreOrderBMO {
 
     @Autowired
     private IStoreOrderInnerServiceSMO storeOrderInnerServiceSMOImpl;
 
+    @Autowired
+    private IStoreOrderCartInnerServiceSMO storeOrderCartInnerServiceSMOImpl;
+
+    @Autowired
+    private IStoreCartInnerServiceSMO storeCartInnerServiceSMOImpl;
+
+    @Autowired
+    private IGroupBuyInnerServiceSMO groupBuyInnerServiceSMOImpl;
+
+    @Autowired
+    private IGroupBuyProductInnerServiceSMO groupBuyProductInnerServiceSMOImpl;
+
+    @Autowired
+    private IProductSpecValueInnerServiceSMO productSpecValueInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeDetailInnerServiceSMO feeDetailInnerServiceSMOImpl;
+
     /**
      * @param storeOrderPo
      * @return 订单服务能够接受的报文
@@ -22,13 +69,163 @@ public class UpdateStoreOrderBMOImpl implements IUpdateStoreOrderBMO {
     @Java110Transactional
     public ResponseEntity<String> update(StoreOrderPo storeOrderPo) {
 
+        StoreOrderDto storeOrderDto = new StoreOrderDto();
+        storeOrderDto.setOrderId(storeOrderPo.getOrderId());
+        storeOrderDto.setState(StoreOrderDto.STATE_WAIT_PAY);
+
+        List<StoreOrderDto> storeOrderDtos = storeOrderInnerServiceSMOImpl.queryStoreOrders(storeOrderDto);
+
+        Assert.listOnlyOne(storeOrderDtos, "当前未找到相应订单");
+
+        storeOrderPo.setState(StoreOrderDto.STATE_FINISH_PAY);
         int flag = storeOrderInnerServiceSMOImpl.updateStoreOrder(storeOrderPo);
+        if (flag < 1) {
+            return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
+        }
+
+        StoreOrderCartDto storeOrderCartDto = new StoreOrderCartDto();
+        storeOrderCartDto.setOrderId(storeOrderPo.getOrderId());
+        storeOrderCartDto.setState(StoreOrderCartDto.STATE_WAIT_BUY);
+        List<StoreOrderCartDto> storeOrderCartDtos = storeOrderCartInnerServiceSMOImpl.queryStoreOrderCarts(storeOrderCartDto);
+
+        if (storeOrderCartDtos == null || storeOrderCartDtos.size() < 1) {
+            throw new IllegalArgumentException("未找到需要购买商品");
+        }
+
+        StoreOrderCartPo storeOrderCartPo = new StoreOrderCartPo();
+        storeOrderCartPo.setOrderId(storeOrderPo.getOrderId());
+        storeOrderCartPo.setState(StoreOrderCartDto.STATE_WAIT_SEND);
+        flag = storeOrderCartInnerServiceSMOImpl.updateStoreOrderCart(storeOrderCartPo);
+        if (flag < 1) {
+            return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存购物车失败");
+        }
+
+
+        for (StoreOrderCartDto tmpStoreOrderCartDto : storeOrderCartDtos) {
+            doDealStoreCart(tmpStoreOrderCartDto);
+            doDealGroupBuyProduct(tmpStoreOrderCartDto, storeOrderDtos.get(0));
+            doDealStoreCartFee(tmpStoreOrderCartDto, storeOrderDtos.get(0));
+        }
+
+        return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
+
+
+    }
+
+    /**
+     * 购物车收费
+     *
+     * @param tmpStoreOrderCartDto
+     * @param storeOrderDto
+     */
+    private void doDealStoreCartFee(StoreOrderCartDto tmpStoreOrderCartDto, StoreOrderDto storeOrderDto) {
+
+        PayFeeDetailPo payFeeDetailPo = new PayFeeDetailPo();
+        payFeeDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+        payFeeDetailPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        payFeeDetailPo.setStartTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        payFeeDetailPo.setFeeId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_feeId));
+        payFeeDetailPo.setPrimeRate("1.0");
+        payFeeDetailPo.setCycles("1");
+        payFeeDetailPo.setReceivableAmount(tmpStoreOrderCartDto.getPayPrice() + "");
+        payFeeDetailPo.setReceivedAmount(tmpStoreOrderCartDto.getPayPrice() + "");
+        payFeeDetailPo.setCommunityId("-1");
+
+        int flag = feeDetailInnerServiceSMOImpl.saveFeeDetail(payFeeDetailPo);
+        if (flag < 1) {
+            throw new IllegalArgumentException("添加费用明细失败");
+        }
+
+
+        PayFeePo payFeePo = new PayFeePo();
+        payFeePo.setFeeId(payFeeDetailPo.getFeeId());
+        payFeePo.setFeeFlag(FeeDto.FEE_FLAG_ONCE);
+        payFeePo.setIncomeObjId(tmpStoreOrderCartDto.getStoreId());
+        payFeePo.setCommunityId("-1");
+        payFeePo.setUserId("-1");
+        payFeePo.setPayerObjId(tmpStoreOrderCartDto.getPersonId());
+        payFeePo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        payFeePo.setFeeTypeCd(FeeConfigDto.FEE_TYPE_CD_SYSTEM);
+        payFeePo.setAmount(tmpStoreOrderCartDto.getPayPrice() + "");
+        payFeePo.setState(FeeDto.STATE_FINISH);
+        payFeePo.setStartTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        payFeePo.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_RENTING);
+        payFeePo.setConfigId(FeeConfigDto.CONFIG_ID_GOODS);
+        List<PayFeePo> payFeePos = new ArrayList<>();
+        payFeePos.add(payFeePo);
+        flag = feeInnerServiceSMOImpl.saveFee(payFeePos);
+
+        if (flag < 1) {
+            throw new IllegalArgumentException("添加费用明细失败");
+        }
+    }
+
+    private void doDealGroupBuyProduct(StoreOrderCartDto tmpStoreOrderCartDto, StoreOrderDto storeOrderDto) {
+
+        GroupBuyProductDto groupBuyProductDto = new GroupBuyProductDto();
+        groupBuyProductDto.setProductId(tmpStoreOrderCartDto.getProductId());
+        groupBuyProductDto.setStoreId(tmpStoreOrderCartDto.getStoreId());
+        List<GroupBuyProductDto> groupBuyProductDtos = groupBuyProductInnerServiceSMOImpl.queryGroupBuyProducts(groupBuyProductDto);
+
+        if (groupBuyProductDtos == null || groupBuyProductDtos.size() < 1) {
+            return;
+        }
+
+        ProductSpecValueDto productSpecValueDto = new ProductSpecValueDto();
+        productSpecValueDto.setProductId(tmpStoreOrderCartDto.getProductId());
+        productSpecValueDto.setValueId(tmpStoreOrderCartDto.getValueId());
+        productSpecValueDto.setStoreId(tmpStoreOrderCartDto.getStoreId());
+        List<ProductSpecValueDto> productSpecValueDtos = productSpecValueInnerServiceSMOImpl.queryProductSpecValues(productSpecValueDto);
+        if (productSpecValueDtos == null || productSpecValueDtos.size() < 1) {
+            throw new IllegalArgumentException("未找到需要购买商品规格");
+        }
+        GroupBuyPo groupBuyPo = new GroupBuyPo();
+        groupBuyPo.setAmount(tmpStoreOrderCartDto.getPayPrice());
+        groupBuyPo.setBatchId(groupBuyProductDtos.get(0).getBatchId());
+        groupBuyPo.setBuyCount(tmpStoreOrderCartDto.getCartNum());
+        groupBuyPo.setBuyId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_buyId));
+        groupBuyPo.setGroupId(groupBuyProductDtos.get(0).getGroupId());
+        groupBuyPo.setGroupPrice(tmpStoreOrderCartDto.getPayPrice());
+        groupBuyPo.setPersionId(tmpStoreOrderCartDto.getPersonId());
+        groupBuyPo.setPersionName(storeOrderDto.getPersonName());
+        groupBuyPo.setProductId(tmpStoreOrderCartDto.getProductId());
+        groupBuyPo.setSpecId(productSpecValueDtos.get(0).getSpecId());
+        groupBuyPo.setState(GroupBuyDto.STATE_SUCCESS);
+        groupBuyPo.setStoreId(tmpStoreOrderCartDto.getStoreId());
+
+        int flag = groupBuyInnerServiceSMOImpl.saveGroupBuy(groupBuyPo);
+
+        if (flag < 1) {
+            throw new IllegalArgumentException("添加拼团失败");
+        }
+
+    }
+
+    /**
+     * 处理订单 购物车 和  拼团
+     *
+     * @param tmpStoreOrderCartDto
+     */
+    private void doDealStoreCart(StoreOrderCartDto tmpStoreOrderCartDto) {
+        StoreCartDto storeCartDto = new StoreCartDto();
+        storeCartDto.setCartId(tmpStoreOrderCartDto.getCartId());
+        storeCartDto.setStoreId(tmpStoreOrderCartDto.getStoreId());
+        List<StoreCartDto> storeCarts = storeCartInnerServiceSMOImpl.queryStoreCarts(storeCartDto);
+
+        if (storeCarts == null || storeCarts.size() < 1) {
+            return;
+        }
+
+        StoreCartPo storeCartPo = new StoreCartPo();
+        storeCartPo.setCartId(tmpStoreOrderCartDto.getCartId());
+        storeCartPo.setStoreId(tmpStoreOrderCartDto.getStoreId());
+        storeCartPo.setState(StoreCartDto.STATE_FINISH_BUY);
+        int flag = storeCartInnerServiceSMOImpl.updateStoreCart(storeCartPo);
 
-        if (flag > 0) {
-            return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
+        if (flag < 1) {
+            throw new IllegalArgumentException("修改购物车失败");
         }
 
-        return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
     }
 
 }