Browse Source

BUG修改

Shanks 6 năm trước cách đây
mục cha
commit
d1c877fd21
42 tập tin đã thay đổi với 1252 bổ sung217 xóa
  1. 4 0
      src/main/java/com/ygj/yuemum/controller/distributionchannel/DcIntroducerController.java
  2. 7 2
      src/main/java/com/ygj/yuemum/controller/distributionchannel/MdjCalculate.java
  3. 5 1
      src/main/java/com/ygj/yuemum/controller/distributionchannel/MiniAppController.java
  4. 8 0
      src/main/java/com/ygj/yuemum/controller/order/YSOrderController.java
  5. 24 0
      src/main/java/com/ygj/yuemum/controller/order/YSOrderReturnController.java
  6. 29 0
      src/main/java/com/ygj/yuemum/controller/order/YSOrderServiceLogController.java
  7. 4 0
      src/main/java/com/ygj/yuemum/controller/pay/CustomerPayController.java
  8. 4 0
      src/main/java/com/ygj/yuemum/dao/distributionchannel/DcIntroduceLogDao.java
  9. 1 0
      src/main/java/com/ygj/yuemum/dao/distributionchannel/DcIntroducerDao.java
  10. 1 0
      src/main/java/com/ygj/yuemum/dao/global/PackagesDao.java
  11. 2 0
      src/main/java/com/ygj/yuemum/dao/maternitymatron/MmStockDao.java
  12. 2 0
      src/main/java/com/ygj/yuemum/dao/order/YSOrderDao.java
  13. 11 0
      src/main/java/com/ygj/yuemum/dao/order/YSOrderReturnDao.java
  14. 25 0
      src/main/java/com/ygj/yuemum/dao/order/YSOrderServiceLogDao.java
  15. 1 0
      src/main/java/com/ygj/yuemum/dao/pay/CustomerPayDao.java
  16. 8 0
      src/main/java/com/ygj/yuemum/domain/distributionchannel/DcIntroduceLog.java
  17. 9 0
      src/main/java/com/ygj/yuemum/domain/distributionchannel/DcIntroducer.java
  18. 6 6
      src/main/java/com/ygj/yuemum/domain/distributionchannel/DcIntroducerExtract.java
  19. 9 0
      src/main/java/com/ygj/yuemum/domain/global/Packages.java
  20. 81 74
      src/main/java/com/ygj/yuemum/domain/order/YSOrder.java
  21. 77 0
      src/main/java/com/ygj/yuemum/domain/order/YSOrderReturn.java
  22. 131 0
      src/main/java/com/ygj/yuemum/domain/order/YSOrderServiceLog.java
  23. 23 8
      src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroduceLogService.java
  24. 1 0
      src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroducerApplicantService.java
  25. 1 1
      src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroducerExtractService.java
  26. 24 1
      src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroducerService.java
  27. 20 0
      src/main/java/com/ygj/yuemum/service/distributionchannel/MiniAppService.java
  28. 3 0
      src/main/java/com/ygj/yuemum/service/global/PackagesService.java
  29. 4 0
      src/main/java/com/ygj/yuemum/service/maternitymatron/MmStockService.java
  30. 45 0
      src/main/java/com/ygj/yuemum/service/order/YSOrderReturnService.java
  31. 192 65
      src/main/java/com/ygj/yuemum/service/order/YSOrderService.java
  32. 58 0
      src/main/java/com/ygj/yuemum/service/order/YSOrderServiceLogService.java
  33. 12 3
      src/main/java/com/ygj/yuemum/service/pay/CustomerPayService.java
  34. 4 2
      src/main/java/com/ygj/yuemum/shiro/ShiroConfig.java
  35. 45 11
      src/main/resources/mybatis/mapper/distributionchannel/DcIntroduceLogMapper.xml
  36. 40 0
      src/main/resources/mybatis/mapper/distributionchannel/DcIntroducerMapper.xml
  37. 8 0
      src/main/resources/mybatis/mapper/global/PackagesMapper.xml
  38. 8 2
      src/main/resources/mybatis/mapper/maternitymatron/MmStockMapper.xml
  39. 62 41
      src/main/resources/mybatis/mapper/order/YSOrder.xml
  40. 80 0
      src/main/resources/mybatis/mapper/order/YSOrderReturn.xml
  41. 163 0
      src/main/resources/mybatis/mapper/order/YSOrderServiceLog.xml
  42. 10 0
      src/main/resources/mybatis/mapper/pay/CustomerPayMapper.xml

+ 4 - 0
src/main/java/com/ygj/yuemum/controller/distributionchannel/DcIntroducerController.java

@@ -34,6 +34,10 @@ public class DcIntroducerController {
     public DcIntroducer checkDcIntroducers(@RequestParam("wv_phone")  String wv_phone) {
         return dcIntroducerService.checkDcIntroducers(wv_phone);
     }
+    @GetMapping("/queryOneDcIntroducer")
+    public DcIntroducer queryOneDcIntroducer(@RequestParam("wv_phone")  String wv_phone) {
+        return dcIntroducerService.queryOneDcIntroducer(wv_phone);
+    }
 
     @GetMapping("/queryDcIntroducersByUser")
     public List<DcIntroducer> queryDcIntroducersByUser(@RequestParam("xul_phone")  String xul_phone) {

+ 7 - 2
src/main/java/com/ygj/yuemum/controller/distributionchannel/MdjCalculate.java

@@ -3,6 +3,7 @@ package com.ygj.yuemum.controller.distributionchannel;
 import com.alibaba.fastjson.JSONObject;
 import com.ygj.yuemum.component.Constant;
 import com.ygj.yuemum.domain.admin.MdjCalculateOrder;
+import com.ygj.yuemum.service.global.PackagesService;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -10,6 +11,7 @@ import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -18,6 +20,8 @@ import java.io.IOException;
 @RestController
 public class MdjCalculate {
     public static final String extracttemplateid = Constant.MDJAPIURL;
+    @Autowired
+    private PackagesService packagesService;
     @PostMapping("/mdjCalculate")
     public String mdjCalculate(@ModelAttribute MdjCalculateOrder mdjCalculateOrder) throws IOException {
         HttpPost httpPost = new HttpPost(extracttemplateid);
@@ -26,11 +30,12 @@ public class MdjCalculate {
         JSONObject jsonParam = new JSONObject();
         jsonParam.put("odCityCode", mdjCalculateOrder.getOdCityCode());
         jsonParam.put("odAmount", mdjCalculateOrder.getOdAmount());
-        jsonParam.put("odNo", mdjCalculateOrder.getOdAmount());
+        jsonParam.put("odNo", mdjCalculateOrder.getOdNo());
         jsonParam.put("odPhone", mdjCalculateOrder.getOdPhone());
         jsonParam.put("odStatus", 1);
         jsonParam.put("odIntroducerPhone", mdjCalculateOrder.getOdIntroducerPhone());
-        jsonParam.put("odProductItem", mdjCalculateOrder.getOdProductItem());
+        jsonParam.put("odProductLine", "ys");
+        jsonParam.put("odProduct",packagesService.getPackageCRMCode(mdjCalculateOrder.getOdProductItem()));
         StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");//解决中文乱码问题
         entity.setContentEncoding("UTF-8");
         entity.setContentType("application/json");

+ 5 - 1
src/main/java/com/ygj/yuemum/controller/distributionchannel/MiniAppController.java

@@ -15,5 +15,9 @@ public class MiniAppController {
     public String createQrCode(@RequestParam("phone")  String phone) {
         return miniAppService.createQrCode(phone);
     }
-
+    @GetMapping("/initQrcode")
+    public int initQrcode() {
+        return  miniAppService.initQrcode();
+    }
 }
+

+ 8 - 0
src/main/java/com/ygj/yuemum/controller/order/YSOrderController.java

@@ -3,6 +3,7 @@ package com.ygj.yuemum.controller.order;
 
 import com.alibaba.fastjson.JSONObject;
 import com.ygj.yuemum.domain.order.YSOrder;
+import com.ygj.yuemum.domain.order.YSOrderServiceLog;
 import com.ygj.yuemum.service.order.YSOrderService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -74,4 +75,11 @@ public class YSOrderController {
     public String getOdno() {
         return YSOrderService.getOdno();
     }
+    @PostMapping("/changMM")
+    public int updateYSOrder(@ModelAttribute YSOrderServiceLog ysOrderServiceLog) {
+        return YSOrderService.changMM(ysOrderServiceLog);
+    }
+
+
+
 }

+ 24 - 0
src/main/java/com/ygj/yuemum/controller/order/YSOrderReturnController.java

@@ -0,0 +1,24 @@
+package com.ygj.yuemum.controller.order;
+
+
+import com.ygj.yuemum.domain.order.YSOrderReturn;
+import com.ygj.yuemum.service.order.YSOrderReturnService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+public class YSOrderReturnController {
+
+    @Autowired
+    private YSOrderReturnService ysOrderReturnService;
+
+
+    @PostMapping("/insertYSOrderReturn")
+    public int insertYSOrderReturn(@ModelAttribute YSOrderReturn ysOrderReturn) {
+        return ysOrderReturnService.insertYSOrderReturn(ysOrderReturn);
+    }
+    @GetMapping("/queryYSOrderReturn")
+    public YSOrderReturn queryYSOrderReturn(@RequestParam("od_no") String od_no) {
+        return ysOrderReturnService.queryYSOrderReturn(od_no);
+    }
+}

+ 29 - 0
src/main/java/com/ygj/yuemum/controller/order/YSOrderServiceLogController.java

@@ -0,0 +1,29 @@
+package com.ygj.yuemum.controller.order;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.ygj.yuemum.service.order.YSOrderServiceLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@RestController
+public class YSOrderServiceLogController {
+
+    @Autowired
+    private YSOrderServiceLogService ysOrderServiceLogService;
+
+    @GetMapping("/checkSLStartDate")
+    public String checkSLStartDate(@RequestParam("od_no") String od_no) {
+        return ysOrderServiceLogService.checkSLStartDate(od_no);
+    }
+    @GetMapping("/selectYSOrderServiceLog")
+    public String selectYSOrderServiceLog(@RequestParam("od_no") String od_no,@RequestParam("page") Integer page,@RequestParam("limit") Integer limit) {
+        Map<String, Object> orderTemps = ysOrderServiceLogService.selectYSOrderServiceLog(od_no, page, limit);
+        String jso = JSONObject.toJSONString(orderTemps);
+        return jso;
+    }
+}

+ 4 - 0
src/main/java/com/ygj/yuemum/controller/pay/CustomerPayController.java

@@ -33,4 +33,8 @@ public class CustomerPayController {
         return  customerPayService.insertYsOrderPay(customerPay);
     }
 
+    @PostMapping("/checkCustomerPay")
+    public int checkCustomerPay(@ModelAttribute CustomerPay customerPay) {
+        return  customerPayService.checkCustomerPay(customerPay);
+    }
 }

+ 4 - 0
src/main/java/com/ygj/yuemum/dao/distributionchannel/DcIntroduceLogDao.java

@@ -23,5 +23,9 @@ public interface DcIntroduceLogDao {
 
     List<DcIntroduceLog> getDcIntroduceLogs(String phone);
 
+    List<DcIntroduceLog> getDcIntroduceLogFive(String phone);
+    List<DcIntroduceLog> getDcIntroduceLogTwo(String phone);
+
+
 
 }

+ 1 - 0
src/main/java/com/ygj/yuemum/dao/distributionchannel/DcIntroducerDao.java

@@ -20,6 +20,7 @@ public interface DcIntroducerDao {
     List<DcIntroducer> queryDcIntroducers(DcIntroducer dcIntroducer);
 
     DcIntroducer checkDcIntroducers(String wv_phone);
+    DcIntroducer queryOneDcIntroducer(String wv_phone);
 
     int delAccountNumber(String wv_phone);
 

+ 1 - 0
src/main/java/com/ygj/yuemum/dao/global/PackagesDao.java

@@ -13,4 +13,5 @@ public interface PackagesDao {
     List<Packages> getPackageShowname();
     List<Packages> getPackageLists();
     Packages getPackageDetail(String p_code);
+    String getPackageCRMCode(String p_code);
 }

+ 2 - 0
src/main/java/com/ygj/yuemum/dao/maternitymatron/MmStockDao.java

@@ -22,6 +22,8 @@ public interface MmStockDao {
 
     int getStockCount(Integer id);
 
+    int deleteOrderStock(MmStock mmStock);
+
 
     int updateByPrimaryKeySelective(MmStock record);
 }

+ 2 - 0
src/main/java/com/ygj/yuemum/dao/order/YSOrderDao.java

@@ -34,6 +34,8 @@ public interface YSOrderDao {
 
     int updateByPrimaryKeySelective(YSOrder record);
 
+    int updateMMChange(YSOrder ysOrder);
+
 
 
 }

+ 11 - 0
src/main/java/com/ygj/yuemum/dao/order/YSOrderReturnDao.java

@@ -0,0 +1,11 @@
+package com.ygj.yuemum.dao.order;
+
+import com.ygj.yuemum.domain.order.YSOrderReturn;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface YSOrderReturnDao {
+
+    int insertSelective(YSOrderReturn record);
+    YSOrderReturn queryYSOrderReturn(String od_no);
+}

+ 25 - 0
src/main/java/com/ygj/yuemum/dao/order/YSOrderServiceLogDao.java

@@ -0,0 +1,25 @@
+package com.ygj.yuemum.dao.order;
+
+import com.ygj.yuemum.domain.order.YSOrderServiceLog;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface YSOrderServiceLogDao {
+
+    List<YSOrderServiceLog> queryYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog);
+
+    int updateYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog);
+
+    int insertYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog);
+
+    int checkYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog);
+
+    String checkSLStartDate(String od_no);
+
+    List<YSOrderServiceLog> selectYSOrderServiceLog(String od_no);
+
+
+
+}

+ 1 - 0
src/main/java/com/ygj/yuemum/dao/pay/CustomerPayDao.java

@@ -11,4 +11,5 @@ public interface CustomerPayDao {
     List<CustomerPay> selectCustomerPay(String cp_orderno);
     int insertCustomerPay(CustomerPay customerPay);
     CustomerPay queryYSOrderPay(CustomerPay customerPay);
+    int checkCustomerPay (CustomerPay customerPay);
 }

+ 8 - 0
src/main/java/com/ygj/yuemum/domain/distributionchannel/DcIntroduceLog.java

@@ -15,7 +15,15 @@ public class DcIntroduceLog {
     private Integer od_rebate_amount;
     private Integer xul_pm_type;
     private String xul_orderno;
+    private Float xul_rebateamount;
 
+    public Float getXul_rebateamount() {
+        return xul_rebateamount;
+    }
+
+    public void setXul_rebateamount(Float xul_rebateamount) {
+        this.xul_rebateamount = xul_rebateamount;
+    }
 
     public Integer getOd_rebate_amount() {
         return od_rebate_amount;

+ 9 - 0
src/main/java/com/ygj/yuemum/domain/distributionchannel/DcIntroducer.java

@@ -6,6 +6,7 @@ public class DcIntroducer {
     private String wv_phone;
     private String wv_phoneOld;
     private Integer wv_gradeid;
+    private Integer wv_status;
     private Double wv_Introduction_total;
     private Double wv_withdraw_total;
     private Integer wv_Introduction_count;
@@ -23,6 +24,14 @@ public class DcIntroducer {
     private Integer page;
     private Integer limit;
 
+    public Integer getWv_status() {
+        return wv_status;
+    }
+
+    public void setWv_status(Integer wv_status) {
+        this.wv_status = wv_status;
+    }
+
     public String getWv_phoneOld() {
         return wv_phoneOld;
     }

+ 6 - 6
src/main/java/com/ygj/yuemum/domain/distributionchannel/DcIntroducerExtract.java

@@ -9,9 +9,9 @@ public class DcIntroducerExtract {
     private String wue_orderno;
     private Integer wue_type;
     private String wue_applydate;
-    private Double wue_applysum;
+    private Float wue_applysum;
     private String wue_approverdate;
-    private Integer wue_approversum;
+    private Float wue_approversum;
     private String wue_approveruser;
     private String wue_paydate;
     private String wue_remarks;
@@ -75,19 +75,19 @@ public class DcIntroducerExtract {
         this.wue_type = wue_type;
     }
 
-    public Double getWue_applysum() {
+    public Float getWue_applysum() {
         return wue_applysum;
     }
 
-    public void setWue_applysum(Double wue_applysum) {
+    public void setWue_applysum(Float wue_applysum) {
         this.wue_applysum = wue_applysum;
     }
 
-    public Integer getWue_approversum() {
+    public Float getWue_approversum() {
         return wue_approversum;
     }
 
-    public void setWue_approversum(Integer wue_approversum) {
+    public void setWue_approversum(Float wue_approversum) {
         this.wue_approversum = wue_approversum;
     }
 

+ 9 - 0
src/main/java/com/ygj/yuemum/domain/global/Packages.java

@@ -3,6 +3,7 @@ package com.ygj.yuemum.domain.global;
 public class Packages {
     private Integer id;
     private String p_code;
+    private String p_crmCode;
     private Integer p_type;
     private String p_name;
     private Integer p_days;
@@ -15,6 +16,14 @@ public class Packages {
     private String p_detailimg;
     private String p_detaildesc;
 
+    public String getP_crmCode() {
+        return p_crmCode;
+    }
+
+    public void setP_crmCode(String p_crmCode) {
+        this.p_crmCode = p_crmCode;
+    }
+
     public Integer getP_show() {
         return p_show;
     }

+ 81 - 74
src/main/java/com/ygj/yuemum/domain/order/YSOrder.java

@@ -11,6 +11,7 @@ public class YSOrder {
     private String od_startdate;
     private String od_enddate;
     private Integer od_mmid;
+    private Integer od_mmidOld;
     private String od_mmname;
     private Integer od_product_id;
     private Integer od_product_item_id;
@@ -22,14 +23,14 @@ public class YSOrder {
     private String od_introducer_phone;
     private String od_introducer_phoneOld;
     private Integer od_introducer_consultant;
-    private Integer od_order_amount;
-    private Integer od_order_pay_amount;
-    private Integer od_mgm_discount;
-    private Integer od_promotion_discount;
-    private Integer od_other_discount;
-    private Integer od_rebate_amount;
-    private Integer od_earnestpay;
-    private Integer od_balancepay;
+    private Float od_order_amount;
+    private Float od_order_pay_amount;
+    private Float od_mgm_discount;
+    private Float od_promotion_discount;
+    private Float od_other_discount;
+    private Float od_rebate_amount;
+    private Float od_earnestpay;
+    private Float od_balancepay;
     private Integer od_promotion_id;
     private Integer od_ismdj;
     private String od_mdjstartdate;
@@ -48,6 +49,14 @@ public class YSOrder {
         this.od_introducer_phoneOld = od_introducer_phoneOld;
     }
 
+    public Integer getOd_mmidOld() {
+        return od_mmidOld;
+    }
+
+    public void setOd_mmidOld(Integer od_mmidOld) {
+        this.od_mmidOld = od_mmidOld;
+    }
+
     public String getOd_product_img() {
         return od_product_img;
     }
@@ -67,40 +76,6 @@ public class YSOrder {
         this.od_promotion_id = od_promotion_id;
     }
 
-    public Integer getOd_earnestpay() {
-        return od_earnestpay;
-    }
-
-    public void setOd_earnestpay(Integer od_earnestpay) {
-        this.od_earnestpay = od_earnestpay;
-    }
-
-    public Integer getOd_balancepay() {
-        return od_balancepay;
-    }
-
-    public void setOd_balancepay(Integer od_balancepay) {
-        this.od_balancepay = od_balancepay;
-    }
-
-    public Integer getOd_order_pay_amount() {
-        return od_order_pay_amount;
-    }
-
-    public void setOd_order_pay_amount(Integer od_order_pay_amount) {
-        this.od_order_pay_amount = od_order_pay_amount;
-    }
-
-    public Integer getOd_rebate_amount() {
-        return od_rebate_amount;
-    }
-
-    public void setOd_rebate_amount(Integer od_rebate_amount) {
-        this.od_rebate_amount = od_rebate_amount;
-    }
-
-
-
     public String getOd_user_address() {
         return od_user_address;
     }
@@ -269,38 +244,6 @@ public class YSOrder {
         this.od_introducer_consultant = od_introducer_consultant;
     }
 
-    public Integer getOd_order_amount() {
-        return od_order_amount;
-    }
-
-    public void setOd_order_amount(Integer od_order_amount) {
-        this.od_order_amount = od_order_amount;
-    }
-
-    public Integer getOd_mgm_discount() {
-        return od_mgm_discount;
-    }
-
-    public void setOd_mgm_discount(Integer od_mgm_discount) {
-        this.od_mgm_discount = od_mgm_discount;
-    }
-
-    public Integer getOd_promotion_discount() {
-        return od_promotion_discount;
-    }
-
-    public void setOd_promotion_discount(Integer od_promotion_discount) {
-        this.od_promotion_discount = od_promotion_discount;
-    }
-
-    public Integer getOd_other_discount() {
-        return od_other_discount;
-    }
-
-    public void setOd_other_discount(Integer od_other_discount) {
-        this.od_other_discount = od_other_discount;
-    }
-
     public Integer getOd_ismdj() {
         return od_ismdj;
     }
@@ -356,4 +299,68 @@ public class YSOrder {
     public void setLimit(Integer limit) {
         this.limit = limit;
     }
+
+    public Float getOd_order_amount() {
+        return od_order_amount;
+    }
+
+    public void setOd_order_amount(Float od_order_amount) {
+        this.od_order_amount = od_order_amount;
+    }
+
+    public Float getOd_order_pay_amount() {
+        return od_order_pay_amount;
+    }
+
+    public void setOd_order_pay_amount(Float od_order_pay_amount) {
+        this.od_order_pay_amount = od_order_pay_amount;
+    }
+
+    public Float getOd_mgm_discount() {
+        return od_mgm_discount;
+    }
+
+    public void setOd_mgm_discount(Float od_mgm_discount) {
+        this.od_mgm_discount = od_mgm_discount;
+    }
+
+    public Float getOd_promotion_discount() {
+        return od_promotion_discount;
+    }
+
+    public void setOd_promotion_discount(Float od_promotion_discount) {
+        this.od_promotion_discount = od_promotion_discount;
+    }
+
+    public Float getOd_other_discount() {
+        return od_other_discount;
+    }
+
+    public void setOd_other_discount(Float od_other_discount) {
+        this.od_other_discount = od_other_discount;
+    }
+
+    public Float getOd_rebate_amount() {
+        return od_rebate_amount;
+    }
+
+    public void setOd_rebate_amount(Float od_rebate_amount) {
+        this.od_rebate_amount = od_rebate_amount;
+    }
+
+    public Float getOd_earnestpay() {
+        return od_earnestpay;
+    }
+
+    public void setOd_earnestpay(Float od_earnestpay) {
+        this.od_earnestpay = od_earnestpay;
+    }
+
+    public Float getOd_balancepay() {
+        return od_balancepay;
+    }
+
+    public void setOd_balancepay(Float od_balancepay) {
+        this.od_balancepay = od_balancepay;
+    }
 }

+ 77 - 0
src/main/java/com/ygj/yuemum/domain/order/YSOrderReturn.java

@@ -0,0 +1,77 @@
+package com.ygj.yuemum.domain.order;
+
+public class YSOrderReturn {
+
+    private Integer id;
+    private String od_no;
+    private Integer od_mmid;
+    private Integer od_consultantid;
+    private String od_comment;
+    private Integer od_refund;
+    private Integer od_user;
+    private String od_date;
+
+    public Integer getOd_refund() {
+        return od_refund;
+    }
+
+    public void setOd_refund(Integer od_refund) {
+        this.od_refund = od_refund;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getOd_no() {
+        return od_no;
+    }
+
+    public void setOd_no(String od_no) {
+        this.od_no = od_no;
+    }
+
+    public Integer getOd_mmid() {
+        return od_mmid;
+    }
+
+    public void setOd_mmid(Integer od_mmid) {
+        this.od_mmid = od_mmid;
+    }
+
+    public Integer getOd_consultantid() {
+        return od_consultantid;
+    }
+
+    public void setOd_consultantid(Integer od_consultantid) {
+        this.od_consultantid = od_consultantid;
+    }
+
+    public String getOd_comment() {
+        return od_comment;
+    }
+
+    public void setOd_comment(String od_comment) {
+        this.od_comment = od_comment;
+    }
+
+    public Integer getOd_user() {
+        return od_user;
+    }
+
+    public void setOd_user(Integer od_user) {
+        this.od_user = od_user;
+    }
+
+    public String getOd_date() {
+        return od_date;
+    }
+
+    public void setOd_date(String od_date) {
+        this.od_date = od_date;
+    }
+}

+ 131 - 0
src/main/java/com/ygj/yuemum/domain/order/YSOrderServiceLog.java

@@ -0,0 +1,131 @@
+package com.ygj.yuemum.domain.order;
+
+public class YSOrderServiceLog {
+
+    private Integer id;
+    private String od_no;
+    private Integer od_mmid;
+    private Integer od_mmidOld;
+    private String od_mmname;
+    private String od_startdate;
+    private String od_enddate;
+    private String od_comment;
+    private Integer od_type;
+    private String od_changeDate;
+    private Integer od_userid;
+    private String od_username;
+    private Integer page;
+    private Integer limit;
+
+    public String getOd_mmname() {
+        return od_mmname;
+    }
+
+    public void setOd_mmname(String od_mmname) {
+        this.od_mmname = od_mmname;
+    }
+
+    public String getOd_username() {
+        return od_username;
+    }
+
+    public void setOd_username(String od_username) {
+        this.od_username = od_username;
+    }
+
+    public Integer getOd_userid() {
+        return od_userid;
+    }
+
+    public void setOd_userid(Integer od_userid) {
+        this.od_userid = od_userid;
+    }
+
+    public String getOd_changeDate() {
+        return od_changeDate;
+    }
+
+    public void setOd_changeDate(String od_changeDate) {
+        this.od_changeDate = od_changeDate;
+    }
+
+    public String getOd_comment() {
+        return od_comment;
+    }
+
+    public void setOd_comment(String od_comment) {
+        this.od_comment = od_comment;
+    }
+
+    public Integer getOd_mmidOld() {
+        return od_mmidOld;
+    }
+
+    public void setOd_mmidOld(Integer od_mmidOld) {
+        this.od_mmidOld = od_mmidOld;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getOd_no() {
+        return od_no;
+    }
+
+    public void setOd_no(String od_no) {
+        this.od_no = od_no;
+    }
+
+    public Integer getOd_mmid() {
+        return od_mmid;
+    }
+
+    public void setOd_mmid(Integer od_mmid) {
+        this.od_mmid = od_mmid;
+    }
+
+    public String getOd_startdate() {
+        return od_startdate;
+    }
+
+    public void setOd_startdate(String od_startdate) {
+        this.od_startdate = od_startdate;
+    }
+
+    public String getOd_enddate() {
+        return od_enddate;
+    }
+
+    public void setOd_enddate(String od_enddate) {
+        this.od_enddate = od_enddate;
+    }
+
+    public Integer getOd_type() {
+        return od_type;
+    }
+
+    public void setOd_type(Integer od_type) {
+        this.od_type = od_type;
+    }
+
+    public Integer getPage() {
+        return page;
+    }
+
+    public void setPage(Integer page) {
+        this.page = page;
+    }
+
+    public Integer getLimit() {
+        return limit;
+    }
+
+    public void setLimit(Integer limit) {
+        this.limit = limit;
+    }
+}

+ 23 - 8
src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroduceLogService.java

@@ -9,10 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class DcIntroduceLogService {
@@ -51,13 +48,13 @@ public class DcIntroduceLogService {
         if (dcIntroduceLog.getXul_introducer_phone() == null || dcIntroduceLog.getXul_introducer_phone().equals("null") || dcIntroduceLog.getXul_introducer_phone() == "" || dcIntroduceLog.getXul_introducer_phone() == " ") {
             return 0;
         } else {
-            int logCount  = dcIntroduceLogDao.checkDcIntroducerLogs(dcIntroduceLog);
+            int logCount = dcIntroduceLogDao.checkDcIntroducerLogs(dcIntroduceLog);
             if (logCount == 0) {
                 if (dcIntroduceLog.getXul_event() == 2) { // 手机号授权介绍人注册用户+1
                     DcIntroducer dcIntroducer = dcIntroducerService.checkDcIntroducers(dcIntroduceLog.getXul_introducer_phone());
                     if (dcIntroducer != null) {
                         // 介绍人注册用户+1
-                        dcIntroducer.setWv_register_count(dcIntroducer.getWv_register_count() + 1 );
+                        dcIntroducer.setWv_register_count(dcIntroducer.getWv_register_count() + 1);
                         dcIntroducerService.updateDcIntroducer(dcIntroducer);
                     }
                 }
@@ -71,13 +68,31 @@ public class DcIntroduceLogService {
     }
 
     public List<DcIntroduceLog> getDcIntroduceLogs(String phone) {
-        return dcIntroduceLogDao.getDcIntroduceLogs(phone);
+        List<DcIntroduceLog> dcIntroduceLog = dcIntroduceLogDao.getDcIntroduceLogs(phone);
+        List<DcIntroduceLog> dcReturn = new ArrayList<>();
+        for (DcIntroduceLog dI : dcIntroduceLog) {
+            if (dI.getXul_event() >= 5) {
+                //取大于5的
+                List<DcIntroduceLog> dcIntroduceLogfile = dcIntroduceLogDao.getDcIntroduceLogFive(dI.getXul_phone());
+                for (DcIntroduceLog idfile : dcIntroduceLogfile) {
+                    dcReturn.add(idfile);
+                }
+            } else {
+                //去等于2的
+                List<DcIntroduceLog> dcIntroduceLogtwo = dcIntroduceLogDao.getDcIntroduceLogTwo(dI.getXul_phone());
+                for (DcIntroduceLog idtwo : dcIntroduceLogtwo) {
+                    dcReturn.add(idtwo);
+                }
+            }
+        }
+        return dcReturn;
     }
 
     public int checkFirstDILogs(DcIntroduceLog dcIntroduceLog) {
         return dcIntroduceLogDao.checkFirstDILogs(dcIntroduceLog);
     }
-    public int updateDcIntroduceLogByPhone (DcIntroduceLog dcIntroduceLog){
+
+    public int updateDcIntroduceLogByPhone(DcIntroduceLog dcIntroduceLog) {
         return dcIntroduceLogDao.updateDcIntroduceLogByPhone(dcIntroduceLog);
     }
 

+ 1 - 0
src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroducerApplicantService.java

@@ -67,6 +67,7 @@ public class DcIntroducerApplicantService {
             DcIntroducer dcIntroducer = new DcIntroducer();
             dcIntroducer.setWv_phone(dcIntroducerApplicant.getWva_phone());
             dcIntroducer.setWv_gradeid(1); //再调整
+            dcIntroducer.setWv_status(1);
             dcIntroducer.setWv_Introduction_total(0.00);
             dcIntroducer.setWv_withdraw_total(0.00);
             dcIntroducer.setWv_Introduction_count(0);

+ 1 - 1
src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroducerExtractService.java

@@ -66,7 +66,7 @@ public class DcIntroducerExtractService {
                 dcIntroducerService.updateDcIntroducer(dcIntroducer);
             }
 
-            if (dcIntroducerExtract.getWue_type() == 3) { //打款 增加体检金额
+            if (dcIntroducerExtract.getWue_type() == 3) { //打款 增加提现金额
                 DcIntroducer dcIntroducer = dcIntroducerService.checkDcIntroducers(dcIntroducerExtract.getWue_phone());
                 dcIntroducer.setWv_withdraw_total(dcIntroducer.getWv_withdraw_total() + dcIntroducerExtract.getWue_approversum());
                 dcIntroducerService.updateDcIntroducer(dcIntroducer);

+ 24 - 1
src/main/java/com/ygj/yuemum/service/distributionchannel/DcIntroducerService.java

@@ -31,7 +31,10 @@ public class DcIntroducerService {
     private DcIntroducerExtractService dcIntroducerExtractService;
     @Autowired
     private DcIntroducerRelationService dcIntroducerRelationService;
+    @Autowired
+    private MiniAppService miniAppService;
     public static final String imgbankcard = Constant.IMGBANKCARD;
+    public static final String qrcode = Constant.QRCODE;
 
     //分页
     public Map<String, Object> getDcIntroducers(int page, int limit) {
@@ -45,6 +48,10 @@ public class DcIntroducerService {
         return tableData;
     }
 
+    public List<DcIntroducer> initIntroducers() {
+        return dcIntroducerDao.getDcIntroducers();
+    }
+
     public Map<String, Object> queryDcIntroducers(DcIntroducer wxVip) {
         PageHelper.startPage(wxVip.getPage(), wxVip.getLimit());
         List<DcIntroducer> dcIntroducers = dcIntroducerDao.queryDcIntroducers(wxVip);
@@ -62,7 +69,7 @@ public class DcIntroducerService {
     }
 
     public int updateDcIntroducer(DcIntroducer dcIntroducer) {
-        //更新介绍人信息,更新介绍人日志信息,更新订单推荐人信息
+        //更新介绍人信息,更新介绍人日志信息,更新订单推荐人信息,重新生成小程序码
         try {
             //订单表
             YSOrder ysOrder = new YSOrder();
@@ -84,6 +91,18 @@ public class DcIntroducerService {
             dcIntroducerRelation.setDig_introducer_phone(dcIntroducer.getWv_phone());
             dcIntroducerRelation.setDig_introducer_phoneOld(dcIntroducer.getWv_phoneOld());
             dcIntroducerRelationService.updateIRByPhoneChange(dcIntroducerRelation);
+            //重新生成小程序码
+            //删除之前生成的小程序码
+            String[] pathname = dcIntroducer.getWv_qrcode().split("/");
+            String name = pathname[pathname.length -1];
+            String path = qrcode + "/"+ name;
+            File dest = new File(path);
+            dest.delete();
+            String qrcodePath = miniAppService.createQrCode(dcIntroducer.getWv_phone());
+            if (qrcodePath.equals("error")) {
+                return 9;
+            }
+            dcIntroducer.setWv_qrcode(qrcodePath);
             //介绍人表
             dcIntroducerDao.updateDcIntroducer(dcIntroducer);
         } catch (Exception ex) {
@@ -105,6 +124,10 @@ public class DcIntroducerService {
         //从CRM里面获取推荐人等级
         return dcIntroducerDao.checkDcIntroducers(wv_phone);
     }
+    public DcIntroducer queryOneDcIntroducer(String wv_phone) {
+        //从CRM里面获取推荐人等级
+        return dcIntroducerDao.queryOneDcIntroducer(wv_phone);
+    }
 
     public int delAccountNumber(String wv_phone) {
         try {

+ 20 - 0
src/main/java/com/ygj/yuemum/service/distributionchannel/MiniAppService.java

@@ -3,6 +3,7 @@ package com.ygj.yuemum.service.distributionchannel;
 import com.alibaba.fastjson.JSON;
 import com.ygj.yuemum.component.Constant;
 import com.ygj.yuemum.dao.global.MiniAppInfoDao;
+import com.ygj.yuemum.domain.distributionchannel.DcIntroducer;
 import com.ygj.yuemum.domain.global.MiniAppInfo;
 import org.apache.http.HttpStatus;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -18,11 +19,14 @@ import org.springframework.stereotype.Service;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 @Service
 public class MiniAppService {
     @Autowired
     private MiniAppInfoDao miniAppInfoDao;
+    @Autowired
+    private DcIntroducerService dcIntroducerService;
     public static final String qrcode = Constant.QRCODE;
     public static final String httpqrcode = Constant.HTTPQRCODE;
     public String createQrCode(String phone) {
@@ -66,4 +70,20 @@ public class MiniAppService {
             return "error";
         }
     }
+    public int initQrcode() {
+        try {
+            List<DcIntroducer> dcIntroducers = dcIntroducerService.initIntroducers();
+            for (DcIntroducer di:dcIntroducers){
+                DcIntroducer dcIntroducerNew = new DcIntroducer();
+                dcIntroducerNew.setId(di.getId());
+                dcIntroducerNew.setWv_phone(di.getWv_phone());
+                dcIntroducerNew.setWv_qrcode(createQrCode(di.getWv_phone()));
+                dcIntroducerService.updateDcIntroducer(dcIntroducerNew);
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return 0;
+        }
+        return 1;
+    }
 }

+ 3 - 0
src/main/java/com/ygj/yuemum/service/global/PackagesService.java

@@ -30,5 +30,8 @@ public class PackagesService {
     public Packages getPackageDetail(String p_code) {
         return packagesDao.getPackageDetail(p_code);
     }
+    public String getPackageCRMCode(String p_code){
+        return packagesDao.getPackageCRMCode(p_code);
+    }
 
 }

+ 4 - 0
src/main/java/com/ygj/yuemum/service/maternitymatron/MmStockService.java

@@ -102,6 +102,10 @@ public class MmStockService {
         return mmStockDao.updateByPrimaryKeySelective(mmStock);
     }
 
+    public int deleteOrderStock (MmStock mmStock) {
+        return mmStockDao.deleteOrderStock(mmStock);
+    }
+
     public List<MmStock> getMmStock(Integer servant_code) {
         return mmStockDao.selectByPrimaryKey(servant_code);
     }

+ 45 - 0
src/main/java/com/ygj/yuemum/service/order/YSOrderReturnService.java

@@ -0,0 +1,45 @@
+package com.ygj.yuemum.service.order;
+
+import com.ygj.yuemum.dao.order.YSOrderDao;
+import com.ygj.yuemum.dao.order.YSOrderReturnDao;
+import com.ygj.yuemum.domain.maternitymatron.MmStock;
+import com.ygj.yuemum.domain.order.YSOrder;
+import com.ygj.yuemum.domain.order.YSOrderReturn;
+import com.ygj.yuemum.service.maternitymatron.MmStockService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class YSOrderReturnService {
+    @Autowired
+    private YSOrderReturnDao ysOrderReturnDao;
+    @Autowired
+    private YSOrderDao ysOrderDao;
+    @Autowired
+    private MmStockService mmStockService;
+
+    public int insertYSOrderReturn (YSOrderReturn ysOrderReturn) {
+        try {
+            ysOrderReturnDao.insertSelective(ysOrderReturn);
+            //更新订单状态为9
+            YSOrder returnYSOrder = new YSOrder();
+            returnYSOrder.setOd_no(ysOrderReturn.getOd_no());
+            returnYSOrder.setOd_status(9);
+            ysOrderDao.updateYsOrderStatus(returnYSOrder);
+            //释放月嫂库存
+            MmStock mmStock = new MmStock();
+            mmStock.setServant_code(ysOrderReturn.getOd_mmid());
+            mmStock.setOrderno(ysOrderReturn.getOd_no());
+            mmStockService.deleteOrderStock(mmStock);
+            //删除介绍人
+
+        }catch (Exception ex) {
+            ex.printStackTrace();
+            return 0;
+        }
+        return 1;
+    }
+    public YSOrderReturn queryYSOrderReturn (String od_no) {
+        return ysOrderReturnDao.queryYSOrderReturn(od_no);
+    }
+}

+ 192 - 65
src/main/java/com/ygj/yuemum/service/order/YSOrderService.java

@@ -10,23 +10,25 @@ import com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog;
 import com.ygj.yuemum.domain.distributionchannel.DcIntroducer;
 import com.ygj.yuemum.domain.maternitymatron.MmStock;
 import com.ygj.yuemum.domain.order.YSOrder;
+import com.ygj.yuemum.domain.order.YSOrderServiceLog;
 import com.ygj.yuemum.service.distributionchannel.DcIntroduceLogService;
 import com.ygj.yuemum.service.distributionchannel.DcIntroducerService;
 import com.ygj.yuemum.service.distributionchannel.MiniAppService;
+import com.ygj.yuemum.service.global.PackagesService;
+import com.ygj.yuemum.service.maternitymatron.MmStockService;
+import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class YSOrderService {
@@ -42,6 +44,12 @@ public class YSOrderService {
     private DcIntroduceLogService dcIntroduceLogService;
     @Autowired
     private MiniAppService miniAppService;
+    @Autowired
+    private MmStockService mmStockService;
+    @Autowired
+    private YSOrderServiceLogService ysOrderServiceLogService;
+    @Autowired
+    private PackagesService packagesService;
 
     //分页
     public Map<String, Object> getYSOrders(int page, int limit) {
@@ -85,11 +93,14 @@ public class YSOrderService {
 
     public int addYSOrder(YSOrder YSOrder) {
         //生成订单号此处再生成
-//        DecimalFormat dfseq = new DecimalFormat("000000");
-//        int seq = YSOrderDao.getAESeq() + 1;
-//        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMdd");
-//        Date date = new Date();
-//        YSOrder.setOd_no("YSDD"+dateFormat.format(date)+dfseq.format(seq));
+        DecimalFormat dfseq1 = new DecimalFormat("000");
+        DecimalFormat dfseq2 = new DecimalFormat("000");
+        Calendar Cld = Calendar.getInstance();
+        int MI = Cld.get(Calendar.MILLISECOND);
+        int seq = YSOrderDao.getAESeq() + 1;
+        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMdd");
+        Date date = new Date();
+        YSOrder.setOd_no("YSBO"+dateFormat.format(date)+dfseq2.format(MI)+dfseq1.format(seq));
         //调用接口
         try {
             YSOrderDao.insertSelective(YSOrder);
@@ -127,7 +138,8 @@ public class YSOrderService {
     public int finishYSOrder(YSOrder ysOrder) {
         try {
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            //更新介绍人状态 完成订单+1
+            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+                    //更新介绍人状态 完成订单+1
             DcIntroducer dcIntroducer = dcIntroducerService.checkDcIntroducers(ysOrder.getOd_introducer_phone());
             if (dcIntroducer != null) {
                 // 介绍人完成订单+1
@@ -142,6 +154,15 @@ public class YSOrderService {
             dcIntroduceLog.setXul_introducer_phone(ysOrder.getOd_introducer_phone());
             dcIntroduceLog.setXul_orderno(ysOrder.getOd_no());
             dcIntroduceLogService.insertDcIntroduceLog(dcIntroduceLog);
+            //释放月嫂库存
+            Date now = new Date();
+            Date enddate = df.parse(ysOrder.getOd_enddate());
+            if(enddate.getTime() > now.getTime()) {
+                MmStock mmStock = new MmStock();
+                mmStock.setServant_code(ysOrder.getOd_mmid());
+                mmStock.setOrderno(ysOrder.getOd_no());
+                mmStockService.deleteOrderStock(mmStock);
+            }
             //更新订单状态
             YSOrderDao.updateByPrimaryKeySelective(ysOrder);
             return 1;
@@ -153,6 +174,7 @@ public class YSOrderService {
 
     public int updateYsOrderStatus(String od_no, Integer od_stauts, Double amount) {
         //锁定月嫂库存,增加介绍人返现金额,增加介绍人日志记录,变成介绍人(参加免单季),修改订单待付金额,传值CRM
+        //支付定金时第二次调用CRM接口
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         YSOrder ysOrder = YSOrderDao.selectByOdNo(od_no);
         try {
@@ -173,24 +195,25 @@ public class YSOrderService {
                         ysOrder.getOd_other_discount() -
                         ysOrder.getOd_order_pay_amount()
                 );
-                // 更新介绍人信息,转介绍单数+1 已签约+1
-                DcIntroducer dcIntroducer = dcIntroducerService.checkDcIntroducers(ysOrder.getOd_introducer_phone());
-                if (dcIntroducer != null) {
-                    // 增加转介绍单数
-                    dcIntroducer.setWv_Introduction_count(dcIntroducer.getWv_Introduction_count() + 1);
-                    //增加已签约单数
-                    dcIntroducer.setWv_contract_count(dcIntroducer.getWv_contract_count() + 1);
-                    //升降级???!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-                    dcIntroducerService.updateDcIntroducer(dcIntroducer);
+                if (ysOrder.getOd_introducer_phone() != null) { //当有介绍人的时候
+                    // 更新介绍人信息,转介绍单数+1 已签约+1
+                    DcIntroducer dcIntroducer = dcIntroducerService.checkDcIntroducers(ysOrder.getOd_introducer_phone());
+                    if (dcIntroducer != null) {
+                        // 增加转介绍单数
+                        dcIntroducer.setWv_Introduction_count(dcIntroducer.getWv_Introduction_count() + 1);
+                        //增加已签约单数
+                        dcIntroducer.setWv_contract_count(dcIntroducer.getWv_contract_count() + 1);
+                        dcIntroducerService.updateDcIntroducer(dcIntroducer);
+                    }
+                    // 增加介绍人日志记录
+                    DcIntroduceLog dcIntroduceLog = new DcIntroduceLog();
+                    dcIntroduceLog.setXul_phone(ysOrder.getOd_phone());
+                    dcIntroduceLog.setXul_event(5);
+                    dcIntroduceLog.setXul_date(sdf.format(new Date()));
+                    dcIntroduceLog.setXul_introducer_phone(ysOrder.getOd_introducer_phone());
+                    dcIntroduceLog.setXul_orderno(ysOrder.getOd_no());
+                    dcIntroduceLogService.insertDcIntroduceLog(dcIntroduceLog);
                 }
-                // 增加介绍人日志记录
-                DcIntroduceLog dcIntroduceLog = new DcIntroduceLog();
-                dcIntroduceLog.setXul_phone(ysOrder.getOd_phone());
-                dcIntroduceLog.setXul_event(5);
-                dcIntroduceLog.setXul_date(sdf.format(new Date()));
-                dcIntroduceLog.setXul_introducer_phone(ysOrder.getOd_introducer_phone());
-                dcIntroduceLog.setXul_orderno(ysOrder.getOd_no());
-                dcIntroduceLogService.insertDcIntroduceLog(dcIntroduceLog);
                 // 变成介绍人(参加免单季)
                 DcIntroducer dcIntroducerMgm = dcIntroducerService.checkDcIntroducers(ysOrder.getOd_phone());
                 if (dcIntroducerMgm == null) {
@@ -203,6 +226,7 @@ public class YSOrderService {
                     DcIntroducer dcIntroducerNew = new DcIntroducer();
                     dcIntroducerNew.setWv_phone(ysOrder.getOd_phone());
                     dcIntroducerNew.setWv_gradeid(1); //再调整
+                    dcIntroducerNew.setWv_status(1);
                     dcIntroducerNew.setWv_Introduction_total(0.00);
                     dcIntroducerNew.setWv_withdraw_total(0.00);
                     dcIntroducerNew.setWv_Introduction_count(0);
@@ -213,8 +237,40 @@ public class YSOrderService {
                     dcIntroducerNew.setWv_finish_count(0);
                     dcIntroducerNew.setWv_contract_count(0);
                     dcIntroducerService.insertDcIntroducer(dcIntroducerNew);
+                    //调用CRM成为介绍人
+                    HttpPost httpPost = new HttpPost(extracttemplateid);
+                    CloseableHttpClient client = HttpClients.createDefault();
+                    String respContent = null;
+                    JSONObject jsonParam = new JSONObject();
+                    jsonParam.put("odCityCode", ysOrder.getOd_cityid());
+                    jsonParam.put("odAmount", ysOrder.getOd_order_amount());
+                    jsonParam.put("odNo", ysOrder.getOd_no());
+                    jsonParam.put("odPhone", ysOrder.getOd_phone());
+                    jsonParam.put("odStatus", 2);
+                    jsonParam.put("odIntroducerPhone", ysOrder.getOd_introducer_phone());
+                    jsonParam.put("odProductLine", "ys");
+                    jsonParam.put("odProduct", packagesService.getPackageCRMCode(String.valueOf(ysOrder.getOd_product_id())));
+                    StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");//解决中文乱码问题
+                    entity.setContentEncoding("UTF-8");
+                    entity.setContentType("application/json");
+                    httpPost.setEntity(entity);
+                    HttpResponse resp = client.execute(httpPost);
+                    if(resp.getStatusLine().getStatusCode() != 200) {
+                        return 0;
+                    }
                 }
+                //支付定金增加订单服务日志
+                YSOrderServiceLog ysOrderServiceLog = new YSOrderServiceLog();
+                ysOrderServiceLog.setOd_no(ysOrder.getOd_no());
+                ysOrderServiceLog.setOd_mmid(ysOrder.getOd_mmid());
+                ysOrderServiceLog.setOd_startdate(ysOrder.getOd_startdate());
+                ysOrderServiceLog.setOd_enddate(ysOrder.getOd_enddate());
+                ysOrderServiceLog.setOd_type(1);
+                ysOrderServiceLog.setOd_changeDate(sdf.format(new Date()));
+                ysOrderServiceLog.setOd_userid(ysOrder.getOd_user());
+                ysOrderServiceLogService.insertYSOrderServiceLog(ysOrderServiceLog);
             } else {
+                //支付尾款时第三次调用CRM接口
                 ysOrder.setOd_balancepay(ysOrder.getOd_order_pay_amount());
                 ysOrder.setOd_order_pay_amount(
                         ysOrder.getOd_order_amount() -
@@ -222,44 +278,56 @@ public class YSOrderService {
                         ysOrder.getOd_promotion_discount() -
                         ysOrder.getOd_other_discount() -
                         ysOrder.getOd_order_pay_amount() -
-                        Integer.valueOf(ysOrder.getOd_earnestpay().toString())
-                );
-                // 支付尾款 +推荐金额增加
-                DcIntroducer dcIntroducer = dcIntroducerService.checkDcIntroducers(ysOrder.getOd_introducer_phone());
-                if (dcIntroducer != null) {
-                    //增加金额
-                    dcIntroducer.setWv_Introduction_total(dcIntroducer.getWv_Introduction_total() + Double.valueOf(ysOrder.getOd_rebate_amount()));
-                    dcIntroducerService.updateDcIntroducer(dcIntroducer);
-                }
-                //介绍人日志
-                DcIntroduceLog dcIntroduceLog = new DcIntroduceLog();
-                dcIntroduceLog.setXul_phone(ysOrder.getOd_phone());
-                dcIntroduceLog.setXul_event(6);
-                dcIntroduceLog.setXul_date(sdf.format(new Date()));
-                dcIntroduceLog.setXul_introducer_phone(ysOrder.getOd_introducer_phone());
-                dcIntroduceLog.setXul_orderno(ysOrder.getOd_no());
-                dcIntroduceLogService.insertDcIntroduceLog(dcIntroduceLog);
-                //回调CRM进行记录
-                HttpPost httpPost = new HttpPost(extracttemplateid);
-                CloseableHttpClient client = HttpClients.createDefault();
-                String respContent = null;
-                JSONObject jsonParam = new JSONObject();
-                jsonParam.put("odCityCode", ysOrder.getOd_cityid());
-                jsonParam.put("odAmount", ysOrder.getOd_order_amount());
-                jsonParam.put("odNo", ysOrder.getOd_no());
-                jsonParam.put("odPhone", ysOrder.getOd_phone());
-                jsonParam.put("odStatus", 3);
-                jsonParam.put("odIntroducerPhone", ysOrder.getOd_introducer_phone());
-                jsonParam.put("odProductItem", ysOrder.getOd_product_id());
-                StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");//解决中文乱码问题
-                entity.setContentEncoding("UTF-8");
-                entity.setContentType("application/json");
-                httpPost.setEntity(entity);
-                HttpResponse resp = client.execute(httpPost);
-                if(resp.getStatusLine().getStatusCode() != 200) {
-//                    HttpEntity he = resp.getEntity();
-//                    respContent = EntityUtils.toString(he,"UTF-8");
-                    return 0;
+                        ysOrder.getOd_earnestpay());
+                if (ysOrder.getOd_introducer_phone() != null) { //当有介绍人的时候
+                    //回调CRM进行记录
+                    HttpPost httpPost = new HttpPost(extracttemplateid);
+                    CloseableHttpClient client = HttpClients.createDefault();
+                    String respContent = null;
+                    JSONObject jsonParam = new JSONObject();
+                    jsonParam.put("odCityCode", ysOrder.getOd_cityid());
+                    jsonParam.put("odAmount", ysOrder.getOd_order_amount());
+                    jsonParam.put("odNo", ysOrder.getOd_no());
+                    jsonParam.put("odPhone", ysOrder.getOd_phone());
+                    jsonParam.put("odStatus", 3);
+                    jsonParam.put("odIntroducerPhone", ysOrder.getOd_introducer_phone());
+                    jsonParam.put("odProductLine", "ys");
+                    jsonParam.put("odProduct", packagesService.getPackageCRMCode(String.valueOf(ysOrder.getOd_product_id())));
+                    StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");//解决中文乱码问题
+                    entity.setContentEncoding("UTF-8");
+                    entity.setContentType("application/json");
+                    httpPost.setEntity(entity);
+                    HttpResponse resp = client.execute(httpPost);
+                    if(resp.getStatusLine().getStatusCode() != 200) {
+                        return 0;
+                    }
+                    HttpEntity he = resp.getEntity();
+                    respContent = EntityUtils.toString(he,"UTF-8");
+                    org.json.JSONObject jsonObject = new org.json.JSONObject(respContent);
+                    int introducerGradeId = jsonObject.getJSONObject("data").getInt("introducerGradeId");
+                    String pm_type = jsonObject.getJSONObject("data").getString("introducerActivityType");
+                    float xul_rebateamount = jsonObject.getJSONObject("data").getInt("rebateAmount");
+                    //介绍人日志
+                    DcIntroduceLog dcIntroduceLog = new DcIntroduceLog();
+                    if (pm_type.equals("mdj")) {
+                        dcIntroduceLog.setXul_pm_type(1);
+                    }
+                    dcIntroduceLog.setXul_rebateamount(xul_rebateamount);
+                    dcIntroduceLog.setXul_phone(ysOrder.getOd_phone());
+                    dcIntroduceLog.setXul_event(6);
+                    dcIntroduceLog.setXul_date(sdf.format(new Date()));
+                    dcIntroduceLog.setXul_introducer_phone(ysOrder.getOd_introducer_phone());
+                    dcIntroduceLog.setXul_orderno(ysOrder.getOd_no());
+                    dcIntroduceLogService.insertDcIntroduceLog(dcIntroduceLog);
+                    // 支付尾款 + 推荐金额增加
+                    DcIntroducer dcIntroducer = dcIntroducerService.checkDcIntroducers(ysOrder.getOd_introducer_phone());
+                    if (dcIntroducer != null) {
+                        //增加金额
+                        dcIntroducer.setWv_Introduction_total(dcIntroducer.getWv_Introduction_total() + Double.valueOf(ysOrder.getOd_rebate_amount()));
+                        dcIntroducer.setWv_gradeid(introducerGradeId);
+                        //升降级
+                        dcIntroducerService.updateDcIntroducer(dcIntroducer);
+                    }
                 }
             }
             // 更新订单状态,修改订单待付金额
@@ -274,6 +342,65 @@ public class YSOrderService {
     public int updateDCPhone(YSOrder ysOrder) {
         return YSOrderDao.updateDCPhone(ysOrder);
     }
+    public int changMM (YSOrderServiceLog ysOrderServiceLog) {
+        //解锁老月嫂库存,锁定新月嫂库存,修改老月嫂服务日志,新增新月嫂服务日志,更新订单服务月嫂
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            YSOrderServiceLog checkLog = new YSOrderServiceLog();
+            checkLog.setOd_changeDate(sdf.format(new Date()));
+            checkLog.setOd_no(ysOrderServiceLog.getOd_no());
+            int checkResult = ysOrderServiceLogService.checkYSOrderServiceLog(checkLog);
+            if (checkResult > 0) {
+                return 9;
+            } else {
+                MmStock mmStockOld = new MmStock();
+                mmStockOld.setServant_code(ysOrderServiceLog.getOd_mmidOld());
+                mmStockOld.setOrderno(ysOrderServiceLog.getOd_no());
+                mmStockDao.deleteOrderStock(mmStockOld);
+
+                MmStock mmStockNew = new MmStock();
+                mmStockNew.setServant_code(ysOrderServiceLog.getOd_mmid());
+                mmStockNew.setOrderno(ysOrderServiceLog.getOd_no());
+                mmStockNew.setStart_date(ysOrderServiceLog.getOd_startdate());
+                mmStockNew.setEnd_date(ysOrderServiceLog.getOd_enddate());
+                mmStockNew.setStock_status(2);
+                mmStockDao.insertSelective(mmStockNew);
+
+                YSOrderServiceLog ysOrderServiceLogOld = new YSOrderServiceLog();
+                ysOrderServiceLogOld.setOd_no(ysOrderServiceLog.getOd_no());
+                ysOrderServiceLogOld.setOd_mmid(ysOrderServiceLog.getOd_mmidOld());
+                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+                Date dt = sdf2.parse(ysOrderServiceLog.getOd_startdate());
+                Calendar rightNow = Calendar.getInstance();
+                rightNow.setTime(dt);
+                rightNow.add(Calendar.DAY_OF_MONTH, -1);
+                Date endDate = rightNow.getTime();
+                ysOrderServiceLogOld.setOd_enddate(sdf.format(endDate));
+                ysOrderServiceLogService.updateYSOrderServiceLog(ysOrderServiceLogOld);
+
+                YSOrderServiceLog ysOrderServiceLogNew = new YSOrderServiceLog();
+                ysOrderServiceLogNew.setOd_no(ysOrderServiceLog.getOd_no());
+                ysOrderServiceLogNew.setOd_mmid(ysOrderServiceLog.getOd_mmid());
+                ysOrderServiceLogNew.setOd_startdate(ysOrderServiceLog.getOd_startdate());
+                ysOrderServiceLogNew.setOd_enddate(ysOrderServiceLog.getOd_enddate());
+                ysOrderServiceLogNew.setOd_changeDate(sdf.format(new Date()));
+                ysOrderServiceLogNew.setOd_type(2);
+                ysOrderServiceLogNew.setOd_userid(ysOrderServiceLog.getOd_userid());
+                ysOrderServiceLogService.insertYSOrderServiceLog(ysOrderServiceLogNew);
+
+                YSOrder ysOrder = new YSOrder();
+                ysOrder.setOd_no(ysOrderServiceLog.getOd_no());
+                ysOrder.setOd_mmidOld(ysOrderServiceLog.getOd_mmidOld());
+                ysOrder.setOd_mmid(ysOrderServiceLog.getOd_mmid());
+                YSOrderDao.updateMMChange(ysOrder);
+
+            }
+        }catch (Exception ex) {
+            System.out.println(ex);
+            return 0;
+        }
+        return 1;
+    }
 
 
 }

+ 58 - 0
src/main/java/com/ygj/yuemum/service/order/YSOrderServiceLogService.java

@@ -0,0 +1,58 @@
+package com.ygj.yuemum.service.order;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ygj.yuemum.dao.order.YSOrderServiceLogDao;
+import com.ygj.yuemum.domain.order.YSOrderServiceLog;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class YSOrderServiceLogService {
+    @Autowired
+    private YSOrderServiceLogDao ysOrderServiceLogDao;
+
+    //分页
+    public Map<String, Object> queryYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog) {
+        PageHelper.startPage(ysOrderServiceLog.getPage(), ysOrderServiceLog.getLimit());
+        List<YSOrderServiceLog> ysOrderServiceLogs = ysOrderServiceLogDao.queryYSOrderServiceLog(ysOrderServiceLog);
+        PageInfo<YSOrderServiceLog> pageInfo = new PageInfo<YSOrderServiceLog>(ysOrderServiceLogs);
+        long count = pageInfo.getTotal(); //获取总记录数
+        Map<String, Object> tableData = new HashMap<>();
+        tableData.put("items", ysOrderServiceLogs);
+        tableData.put("total", count);
+        return tableData;
+    }
+
+    public Map<String, Object> selectYSOrderServiceLog(String od_no,Integer page,Integer limit) {
+        PageHelper.startPage(page, limit);
+        List<YSOrderServiceLog> ysOrderServiceLogs = ysOrderServiceLogDao.selectYSOrderServiceLog(od_no);
+        PageInfo<YSOrderServiceLog> pageInfo = new PageInfo<YSOrderServiceLog>(ysOrderServiceLogs);
+        long count = pageInfo.getTotal(); //获取总记录数
+        Map<String, Object> tableData = new HashMap<>();
+        tableData.put("items", ysOrderServiceLogs);
+        tableData.put("total", count);
+        return tableData;
+    }
+
+
+    public int updateYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog) {
+        return ysOrderServiceLogDao.updateYSOrderServiceLog(ysOrderServiceLog);
+    }
+
+    public int insertYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog) {
+        return ysOrderServiceLogDao.insertYSOrderServiceLog(ysOrderServiceLog);
+    }
+    public int checkYSOrderServiceLog(YSOrderServiceLog ysOrderServiceLog) {
+        return ysOrderServiceLogDao.checkYSOrderServiceLog(ysOrderServiceLog);
+    }
+    public String checkSLStartDate(String od_no) {
+        return ysOrderServiceLogDao.checkSLStartDate(od_no);
+    }
+
+
+}

+ 12 - 3
src/main/java/com/ygj/yuemum/service/pay/CustomerPayService.java

@@ -40,6 +40,9 @@ public class CustomerPayService {
     public CustomerPay queryYSOrderPay (CustomerPay customerPay){
         return customerPayDao.queryYSOrderPay(customerPay);
     }
+    public int checkCustomerPay (CustomerPay customerPay) {
+        return customerPayDao.checkCustomerPay(customerPay);
+    }
     public int insertCustomerPay(CustomerPay customerPay) {
         try{
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -79,9 +82,15 @@ public class CustomerPayService {
 
     public int insertYsOrderPay(CustomerPay customerPay) {
         try{
-            customerPayDao.insertCustomerPay(customerPay);
-            //锁定月嫂库存,增加介绍人返现金额,增加介绍人日志记录,变成介绍人(参加免单季),修改订单待付金额,传值CRM
-            ysOrderService.updateYsOrderStatus(customerPay.getCp_orderno(),customerPay.getCp_orderstatus(),customerPay.getCp_payamount());
+            //验证是否已经付款
+            int payCount = customerPayDao.checkCustomerPay(customerPay);
+            if (payCount <= 0) {
+                customerPayDao.insertCustomerPay(customerPay);
+                //锁定月嫂库存,增加介绍人返现金额,增加介绍人日志记录,变成介绍人(参加免单季),修改订单待付金额,传值CRM
+                ysOrderService.updateYsOrderStatus(customerPay.getCp_orderno(),customerPay.getCp_orderstatus(),customerPay.getCp_payamount());
+            } else {
+                return 9;
+            }
          }catch (Exception ex){
             ex.printStackTrace();
             return 0;

+ 4 - 2
src/main/java/com/ygj/yuemum/shiro/ShiroConfig.java

@@ -26,8 +26,8 @@ public class ShiroConfig {
         Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
 
         //小程序开放权限
-        filterChainDefinitionMap.put("/addEquipmenteHireDetail'", "anon");
-        filterChainDefinitionMap.put("/addEquipmenteHireHeadOnline'", "anon");
+        filterChainDefinitionMap.put("/addEquipmenteHireDetail", "anon");
+        filterChainDefinitionMap.put("/addEquipmenteHireHeadOnline", "anon");
         filterChainDefinitionMap.put("/deleteEquipmenteHireHead", "anon");
         filterChainDefinitionMap.put("/deleteWXUserDefAddress", "anon");
         filterChainDefinitionMap.put("/checkStockDate", "anon");
@@ -77,6 +77,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/queryMineOrder", "anon");
         filterChainDefinitionMap.put("/getYSOrder", "anon");
         filterChainDefinitionMap.put("/insertYsOrderPay", "anon");
+        filterChainDefinitionMap.put("/checkCustomerPay", "anon");
+        filterChainDefinitionMap.put("/queryYSOrderReturn", "anon");
         //萌动开放权限
         filterChainDefinitionMap.put("/getNewUserCoupon", "anon");
         filterChainDefinitionMap.put("/getConsultTaskCoupon", "anon");

+ 45 - 11
src/main/resources/mybatis/mapper/distributionchannel/DcIntroduceLogMapper.xml

@@ -11,6 +11,7 @@
         <result column="xul_introducer_phone" property="xul_introducer_phone" jdbcType="VARCHAR"/>
         <result column="xul_pm_type" property="xul_pm_type" jdbcType="INTEGER"/>
         <result column="xul_orderno" property="xul_orderno" jdbcType="VARCHAR"/>
+        <result column="xul_rebateamount" property="xul_rebateamount" jdbcType="INTEGER"/>
     </resultMap>
 
     <!--获取所有数据-->
@@ -20,6 +21,7 @@
         from dc_introduce_log
         where xul_phone = #{xul_phone,jdbcType=VARCHAR}
         and xul_event = #{xul_event,jdbcType=INTEGER}
+        and xul_openid = #{xul_openid,jdbcType=INTEGER}
         order by id desc
     </select>
 
@@ -43,7 +45,8 @@
         xul_date,
         xul_introducer_phone,
         xul_pm_type,
-        xul_orderno
+        xul_orderno,
+        xul_rebateamount
         from dc_introduce_log
         where 1=1
         <if test="xul_openid != null and xul_openid != ''">
@@ -112,19 +115,44 @@
 
     <select id="getDcIntroduceLogs" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
             parameterType="java.lang.String">
+        select xul_phone,max(xul_event) xul_event from dc_introduce_log
+        where xul_introducer_phone = #{phone,jdbcType=VARCHAR}
+        and xul_event >= 2
+        group by xul_phone
+    </select>
+
+    <select id="getDcIntroduceLogFive" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
+            parameterType="java.lang.String">
         SELECT
-          xul_phone,
-          DATE_FORMAT(min(xul_date), '%Y-%m-%d') xul_date,
-          max(xul_event) xul_event,
-          max(xul_pm_type) xul_pm_type
+            xul_phone,
+            DATE_FORMAT(min(xul_date), '%Y-%m-%d') xul_date,
+            max(xul_event) xul_event,
+            xul_pm_type,
+            xul_rebateamount
         FROM
             dc_introduce_log
         WHERE
-            xul_introducer_phone = #{phone,jdbcType=VARCHAR}
-            and xul_event>= 2
+            xul_phone = #{phone,jdbcType=VARCHAR}
+        AND xul_event >= 5
         GROUP BY
-            xul_phone
-        order by xul_event desc, id desc , xul_pm_type asc
+            xul_orderno
+    </select>
+
+    <select id="getDcIntroduceLogTwo" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
+            parameterType="java.lang.String">
+        SELECT
+            xul_phone,
+            DATE_FORMAT(xul_date, '%Y-%m-%d') xul_date,
+            xul_event,
+            xul_pm_type,
+            xul_rebateamount
+        FROM
+            dc_introduce_log
+        WHERE
+            xul_phone = #{phone,jdbcType=VARCHAR}
+        AND xul_event = 2
+        GROUP BY
+            xul_orderno
     </select>
 
     <insert id="insertDcIntroduceLog" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
@@ -149,7 +177,10 @@
                 xul_pm_type,
             </if>
             <if test="xul_orderno != null">
-                xul_orderno
+                xul_orderno,
+            </if>
+            <if test="xul_rebateamount != null">
+                xul_rebateamount
             </if>
 
         </trim>
@@ -173,7 +204,10 @@
                 #{xul_pm_type,jdbcType=INTEGER},
             </if>
             <if test="xul_orderno != null">
-                #{xul_orderno,jdbcType=VARCHAR}
+                #{xul_orderno,jdbcType=VARCHAR},
+            </if>
+            <if test="xul_rebateamount != null">
+                #{xul_rebateamount,jdbcType=INTEGER}
             </if>
 
         </trim>

+ 40 - 0
src/main/resources/mybatis/mapper/distributionchannel/DcIntroducerMapper.xml

@@ -6,6 +6,7 @@
         <result column="id" property="id" jdbcType="INTEGER"/>
         <result column="wv_phone" property="wv_phone" jdbcType="VARCHAR"/>
         <result column="wv_gradeid" property="wv_gradeid" jdbcType="INTEGER"/>
+        <result column="wv_status" property="wv_status" jdbcType="INTEGER"/>
         <result column="wv_Introduction_total" property="wv_Introduction_total" jdbcType="DECIMAL"/>
         <result column="wv_withdraw_total" property="wv_withdraw_total" jdbcType="DECIMAL"/>
         <result column="wv_Introduction_count" property="wv_Introduction_count" jdbcType="INTEGER"/>
@@ -35,6 +36,35 @@
         id,
         wv_phone,
         wv_gradeid,
+        wv_status,
+        wv_Introduction_total,
+        wv_withdraw_total,
+        wv_Introduction_count,
+        wv_people_count,
+        wv_register_count,
+        wv_contract_count,
+        wv_finish_count,
+        wv_extract_count,
+        wv_qrcode,
+        wv_consultant,
+        fgetuser_name(wv_consultant) wv_consultantname,
+        wv_account_number,
+        wv_account_bank,
+        wv_account_number_path
+        from dc_introducer
+        where wv_phone = #{wv_phone,jdbcType=VARCHAR}
+        and wv_status = 1
+        order by id desc
+    </select>
+
+
+    <select id="queryOneDcIntroducer" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroducer"
+            parameterType="java.lang.String">
+        select
+        id,
+        wv_phone,
+        wv_gradeid,
+        wv_status,
         wv_Introduction_total,
         wv_withdraw_total,
         wv_Introduction_count,
@@ -79,6 +109,7 @@
         id,
         wv_phone,
         wv_gradeid,
+        wv_status,
         wv_Introduction_total,
         wv_withdraw_total,
         wv_Introduction_count,
@@ -152,6 +183,9 @@
             <if test="wv_gradeid != null">
                 wv_gradeid = #{wv_gradeid,jdbcType=INTEGER},
             </if>
+            <if test="wv_status != null">
+                wv_status = #{wv_status,jdbcType=INTEGER},
+            </if>
             <if test="wv_Introduction_total != null">
                 wv_Introduction_total = #{wv_Introduction_total,jdbcType=DECIMAL},
             </if>
@@ -231,6 +265,9 @@
             <if test="wv_gradeid != null">
                 wv_gradeid,
             </if>
+            <if test="wv_status != null">
+                wv_status,
+            </if>
             <if test="wv_Introduction_total != null">
                 wv_Introduction_total,
             </if>
@@ -275,6 +312,9 @@
             <if test="wv_gradeid != null">
                 #{wv_gradeid,jdbcType=INTEGER},
             </if>
+            <if test="wv_status != null">
+                #{wv_status,jdbcType=INTEGER},
+            </if>
             <if test="wv_Introduction_total != null">
                 #{wv_Introduction_total,jdbcType=DECIMAL},
             </if>

+ 8 - 0
src/main/resources/mybatis/mapper/global/PackagesMapper.xml

@@ -5,6 +5,7 @@
     <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.global.Packages" >
         <id column="id" property="id" jdbcType="INTEGER" />
         <result column="p_code" property="p_code" jdbcType="VARCHAR" />
+        <result column="p_crmCode" property="p_crmCode" jdbcType="VARCHAR" />
         <result column="p_type" property="p_type" jdbcType="INTEGER" />
         <result column="p_name" property="p_name" jdbcType="VARCHAR" />
         <result column="p_days" property="p_days" jdbcType="INTEGER" />
@@ -52,4 +53,11 @@
         where p_code = #{p_code,jdbcType=VARCHAR}
     </select>
 
+    <select id="getPackageCRMCode" resultType="java.lang.String"  parameterType="java.lang.String" >
+        select p_crmCode
+        from packages
+        where p_code = #{p_code,jdbcType=VARCHAR}
+    </select>
+
+
 </mapper>

+ 8 - 2
src/main/resources/mybatis/mapper/maternitymatron/MmStockMapper.xml

@@ -6,8 +6,8 @@
         <id column="id" property="id" jdbcType="INTEGER" />
         <result column="servant_code" property="servant_code" jdbcType="INTEGER" />
         <result column="stock_status" property="stock_status" jdbcType="INTEGER" />
-        <result column="start_date" property="start_date" jdbcType="VARCHAR" />
-        <result column="end_date" property="end_date" jdbcType="VARCHAR" />
+        <result column="start_date" property="start_date" jdbcType="DATE" />
+        <result column="end_date" property="end_date" jdbcType="DATE" />
         <result column="orderno" property="orderno" jdbcType="VARCHAR" />
         <result column="adminuser" property="adminuser" jdbcType="VARCHAR" />
     </resultMap>
@@ -76,6 +76,12 @@
         where id = #{id,jdbcType=INTEGER}
     </delete>
 
+    <delete id="deleteOrderStock" parameterType="com.ygj.yuemum.domain.maternitymatron.MmStock" >
+        delete from
+        mm_stock
+        where servant_code = #{servant_code,jdbcType=INTEGER}
+        and orderno =  #{orderno,jdbcType=VARCHAR}
+    </delete>
     <!-- 插入一条库存信息 -->
     <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.maternitymatron.MmStock" >
         insert into mm_stock

+ 62 - 41
src/main/resources/mybatis/mapper/order/YSOrder.xml

@@ -48,6 +48,7 @@
         select
         count(1)
         from ys_order
+        where od_status != 99
     </select>
 
     <select id="checkOrder" resultType="java.lang.Integer" parameterType="java.lang.String">
@@ -56,7 +57,7 @@
         FROM
         ys_order
         WHERE
-        1=1
+        od_status != 99
         <if test="od_phone != null" >
             and od_phone = #{od_phone,jdbcType=VARCHAR}
         </if>
@@ -74,6 +75,7 @@
         od_order_amount,od_order_pay_amount,od_mgm_discount,od_promotion_discount,od_other_discount,od_rebate_amount,
         od_earnestpay,od_balancepay,od_promotion_id,od_ismdj,od_mdjstartdate,od_mdjenddate,od_user,od_date
         from ys_order
+        where od_status != 99
         order by id desc
     </select>
 
@@ -100,14 +102,14 @@
         fgetuser_name(od_consultantid) od_consultantname,
         od_introducer_phone,
         od_introducer_consultant,
-        od_order_amount,
-        od_order_pay_amount,
-        od_mgm_discount,
-        od_promotion_discount,
-        od_other_discount,
-        od_rebate_amount,
-        od_earnestpay,
-        od_balancepay,
+        IFNULL(od_order_amount,0) od_order_amount,
+        IFNULL(od_order_pay_amount,0) od_order_pay_amount,
+        IFNULL(od_mgm_discount,0) od_mgm_discount,
+        IFNULL(od_promotion_discount,0) od_promotion_discount,
+        IFNULL(od_other_discount,0) od_other_discount,
+        IFNULL(od_rebate_amount,0) od_rebate_amount,
+        IFNULL(od_earnestpay,0) od_earnestpay,
+        IFNULL(od_balancepay,0) od_balancepay,
         od_promotion_id,
         od_ismdj,
         od_mdjstartdate,
@@ -116,7 +118,7 @@
         fgetuser_name(od_user) od_username,
         od_date
         from ys_order
-        where 1=1
+        where od_status != 99
         <if test="od_no != null and od_no != ''">
             and od_no like "%"#{od_no,jdbcType=VARCHAR}"%"
         </if>
@@ -195,14 +197,14 @@
         fgetuser_name(od_consultantid) od_consultantname,
         od_introducer_phone,
         od_introducer_consultant,
-        od_order_amount,
-        od_order_pay_amount,
-        od_mgm_discount,
-        od_promotion_discount,
-        od_other_discount,
-        od_rebate_amount,
-        od_earnestpay,
-        od_balancepay,
+        IFNULL(od_order_amount,0) od_order_amount,
+        IFNULL(od_order_pay_amount,0) od_order_pay_amount,
+        IFNULL(od_mgm_discount,0) od_mgm_discount,
+        IFNULL(od_promotion_discount,0) od_promotion_discount,
+        IFNULL(od_other_discount,0) od_other_discount,
+        IFNULL(od_rebate_amount,0) od_rebate_amount,
+        IFNULL(od_earnestpay,0) od_earnestpay,
+        IFNULL(od_balancepay,0) od_balancepay,
         od_promotion_id,
         od_ismdj,
         od_mdjstartdate,
@@ -212,6 +214,7 @@
         DATE_FORMAT(od_date, '%Y-%m-%d') od_date
         from ys_order
         where od_phone = #{od_phone,jdbcType=VARCHAR}
+        and od_status != 99
         order by id desc
     </select>
 
@@ -236,14 +239,14 @@
         fgetuser_name(od_consultantid) od_consultantname,
         od_introducer_phone,
         od_introducer_consultant,
-        od_order_amount,
-        od_order_pay_amount,
-        od_mgm_discount,
-        od_promotion_discount,
-        od_other_discount,
-        od_rebate_amount,
-        od_earnestpay,
-        od_balancepay,
+        IFNULL(od_order_amount,0) od_order_amount,
+        IFNULL(od_order_pay_amount,0) od_order_pay_amount,
+        IFNULL(od_mgm_discount,0) od_mgm_discount,
+        IFNULL(od_promotion_discount,0) od_promotion_discount,
+        IFNULL(od_other_discount,0) od_other_discount,
+        IFNULL(od_rebate_amount,0) od_rebate_amount,
+        IFNULL(od_earnestpay,0) od_earnestpay,
+        IFNULL(od_balancepay,0) od_balancepay,
         od_promotion_id,
         od_ismdj,
         od_mdjstartdate,
@@ -253,6 +256,7 @@
         DATE_FORMAT(od_date, '%Y-%m-%d') od_date
         from ys_order
         where id = #{id,jdbcType=INTEGER}
+        and od_status != 99
     </select>
 
     <select id="selectByOdNo" resultMap="BaseResultMap" parameterType="java.lang.String" >
@@ -276,14 +280,14 @@
         fgetuser_name(od_consultantid) od_consultantname,
         od_introducer_phone,
         od_introducer_consultant,
-        od_order_amount,
-        od_order_pay_amount,
-        od_mgm_discount,
-        od_promotion_discount,
-        od_other_discount,
-        od_rebate_amount,
-        od_earnestpay,
-        od_balancepay,
+        IFNULL(od_order_amount,0) od_order_amount,
+        IFNULL(od_order_pay_amount,0) od_order_pay_amount,
+        IFNULL(od_mgm_discount,0) od_mgm_discount,
+        IFNULL(od_promotion_discount,0) od_promotion_discount,
+        IFNULL(od_other_discount,0) od_other_discount,
+        IFNULL(od_rebate_amount,0) od_rebate_amount,
+        IFNULL(od_earnestpay,0) od_earnestpay,
+        IFNULL(od_balancepay,0) od_balancepay,
         od_promotion_id,
         od_ismdj,
         od_mdjstartdate,
@@ -293,13 +297,19 @@
         od_date
         from ys_order
         where od_no = #{od_no,jdbcType=INTEGER}
+        and od_status != 99
     </select>
 
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
-        delete from ys_order
-        where id = #{id,jdbcType=INTEGER}
-    </delete>
+    <!--<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >-->
+        <!--delete from ys_order-->
+        <!--where id = #{id,jdbcType=INTEGER}-->
+    <!--</delete>-->
 
+    <update id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+        update ys_order
+        set od_status = 99
+        where id = #{id,jdbcType=INTEGER}
+    </update>
     <!-- 插入一条培训信息 -->
     <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.order.YSOrder" >
         insert into ys_order
@@ -364,12 +374,12 @@
             <if test="od_other_discount != null" >
                 od_other_discount,
             </if>
-            <if test="od_earnestpay != null" >
-                od_earnestpay,
-            </if>
             <if test="od_rebate_amount != null" >
                 od_rebate_amount,
             </if>
+            <if test="od_earnestpay != null" >
+                od_earnestpay,
+            </if>
             <if test="od_balancepay != null" >
                 od_balancepay,
             </if>
@@ -620,4 +630,15 @@
         where od_introducer_phone = #{od_introducer_phoneOld,jdbcType=VARCHAR}
     </update>
 
+    <update id="updateMMChange" parameterType="com.ygj.yuemum.domain.order.YSOrder" >
+        update ys_order
+        <set >
+            <if test="od_mmid != null" >
+                od_mmid = #{od_mmid,jdbcType=INTEGER},
+            </if>
+        </set>
+        where od_no = #{od_no,jdbcType=VARCHAR}
+        and od_mmid =  #{od_mmidOld,jdbcType=INTEGER}
+    </update>
+
 </mapper>

+ 80 - 0
src/main/resources/mybatis/mapper/order/YSOrderReturn.xml

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ygj.yuemum.dao.order.YSOrderReturnDao" >
+
+    <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.order.YSOrderReturn" >
+        <id column="id" property="id" jdbcType="INTEGER" />
+        <result column="od_no" property="od_no" jdbcType="VARCHAR" />
+        <result column="od_mmid" property="od_mmid" jdbcType="INTEGER" />
+        <result column="od_consultantid" property="od_consultantid" jdbcType="INTEGER" />
+        <result column="od_comment" property="od_comment" jdbcType="VARCHAR" />
+        <result column="od_refund" property="od_refund" jdbcType="INTEGER" />
+        <result column="od_user" property="od_user" jdbcType="INTEGER" />
+        <result column="od_date" property="od_date" jdbcType="DATE" />
+    </resultMap>
+
+    <sql id="Base_Column_List" >
+        id,od_no,od_mmid,od_consultantid,od_comment,od_refund,od_user,od_date
+    </sql>
+
+    <select id="queryYSOrderReturn" resultMap="BaseResultMap" parameterType="java.lang.String">
+        SELECT
+        *
+        FROM
+        ys_order_return
+        WHERE
+        od_no = #{od_no,jdbcType=VARCHAR}
+    </select>
+
+    <!-- 插入一条培训信息 -->
+    <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.order.YSOrderReturn" >
+        insert into ys_order_return
+        <trim prefix="(" suffix=")" suffixOverrides="," >
+            <if test="od_no != null" >
+                od_no,
+            </if>
+            <if test="od_mmid != null" >
+                od_mmid,
+            </if>
+            <if test="od_consultantid != null" >
+                od_consultantid,
+            </if>
+            <if test="od_comment != null" >
+                od_comment,
+            </if>
+            <if test="od_refund != null" >
+                od_refund,
+            </if>
+            <if test="od_user != null" >
+                od_user,
+            </if>
+            <if test="od_date != null" >
+                od_date
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
+            <if test="od_no != null" >
+                #{od_no,jdbcType=VARCHAR},
+            </if>
+            <if test="od_mmid != null" >
+                #{od_mmid,jdbcType=INTEGER},
+            </if>
+            <if test="od_consultantid != null" >
+                #{od_consultantid,jdbcType=INTEGER},
+            </if>
+            <if test="od_comment != null" >
+                #{od_comment,jdbcType=VARCHAR},
+            </if>
+            <if test="od_refund != null" >
+                #{od_refund,jdbcType=INTEGER},
+            </if>
+            <if test="od_user != null" >
+                #{od_user,jdbcType=INTEGER},
+            </if>
+            <if test="od_date != null" >
+                #{od_date,jdbcType=VARCHAR}
+            </if>
+        </trim>
+    </insert>
+
+</mapper>

+ 163 - 0
src/main/resources/mybatis/mapper/order/YSOrderServiceLog.xml

@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.ygj.yuemum.dao.order.YSOrderServiceLogDao" >
+
+    <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.order.YSOrderServiceLog" >
+        <id column="id" property="id" jdbcType="INTEGER" />
+        <result column="od_no" property="od_no" jdbcType="VARCHAR" />
+        <result column="od_mmid" property="od_mmid" jdbcType="INTEGER" />
+        <result column="od_startdate" property="od_startdate" jdbcType="DATE" />
+        <result column="od_enddate" property="od_enddate" jdbcType="DATE" />
+        <result column="od_type" property="od_type" jdbcType="INTEGER" />
+        <result column="od_comment" property="od_comment" jdbcType="VARCHAR" />
+        <result column="od_changeDate" property="od_changeDate" jdbcType="DATE" />
+        <result column="od_userid" property="od_userid" jdbcType="INTEGER" />
+    </resultMap>
+
+    <sql id="Base_Column_List" >
+        id,od_no,od_mmid,od_startdate,od_enddate,od_type,od_comment,od_changeDate,od_userid
+    </sql>
+
+    <!--获取所有数据-->
+
+    <select id="queryYSOrderServiceLog" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.order.YSOrderServiceLog">
+        select
+        id,
+        od_no,
+        od_mmid,
+        od_startdate,
+        od_enddate,
+        od_type,
+        od_comment,
+        od_changeDate,
+        od_userid
+        from ys_order_servicelog
+        where 1=1
+        <if test="od_no != null and od_no != ''">
+            and od_no like "%"#{od_no,jdbcType=VARCHAR}"%"
+        </if>
+        <if test="od_mmid != null and od_mmid != ''">
+            and od_mmid like "%"#{od_mmid,jdbcType=INTEGER}"%"
+        </if>
+        <if test="od_startdate != null and od_startdate != ''">
+            and DATE_FORMAT(od_startdate,'%Y-%m-%d') = DATE_FORMAT(#{od_startdate,jdbcType=DATE},'%Y-%m-%d')
+        </if>
+        <if test="od_enddate != null and od_enddate != ''">
+            and DATE_FORMAT(od_enddate,'%Y-%m-%d') = DATE_FORMAT(#{od_enddate,jdbcType=DATE},'%Y-%m-%d')
+        </if>
+        <if test="od_type != null and od_type != ''">
+            and od_type = #{od_type,jdbcType=INTEGER}
+        </if>
+        order by id desc
+    </select>
+
+    <select id="checkYSOrderServiceLog" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.order.YSOrderServiceLog">
+        select
+        count(1)
+        from ys_order_servicelog
+        where
+        od_no = #{od_no,jdbcType=VARCHAR}
+        and DATE_FORMAT(od_enddate,'%Y-%m-%d') &lt;= DATE_FORMAT(#{od_changeDate,jdbcType=DATE},'%Y-%m-%d')
+        order by id desc
+    </select>
+
+
+    <select id="selectYSOrderServiceLog" resultMap="BaseResultMap" parameterType="java.lang.String">
+        select
+        id,
+        od_no,
+        od_mmid,
+        fgetmmname (od_mmid) od_mmname,
+        DATE_FORMAT(od_startdate,'%Y-%m-%d') od_startdate,
+        DATE_FORMAT(od_enddate,'%Y-%m-%d') od_enddate,
+        od_type,
+        od_comment,
+        od_changeDate,
+        od_userid,
+        fgetuser_name(od_userid) od_username
+        from ys_order_servicelog
+        where
+        od_no = #{od_no,jdbcType=VARCHAR}
+        order by id desc
+    </select>
+
+    <select id="checkSLStartDate" resultType="java.lang.String" parameterType="java.lang.String">
+        select
+        max(DATE_FORMAT(od_startdate,'%Y-%m-%d')) od_startdate
+        from ys_order_servicelog
+        where
+        od_no = #{od_no,jdbcType=VARCHAR}
+        order by id desc
+    </select>
+
+    <!-- 插入一条培训信息 -->
+    <insert id="insertYSOrderServiceLog" parameterType="com.ygj.yuemum.domain.order.YSOrderServiceLog" >
+        insert into ys_order_servicelog
+        <trim prefix="(" suffix=")" suffixOverrides="," >
+            <if test="od_no != null" >
+                od_no,
+            </if>
+            <if test="od_mmid != null" >
+                od_mmid,
+            </if>
+            <if test="od_startdate != null" >
+                od_startdate,
+            </if>
+            <if test="od_enddate != null" >
+                od_enddate,
+            </if>
+            <if test="od_type != null" >
+                od_type,
+            </if>
+            <if test="od_comment != null" >
+                od_comment,
+            </if>
+            <if test="od_changeDate != null" >
+                od_changeDate,
+            </if>
+            <if test="od_userid != null" >
+                od_userid
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
+            <if test="od_no != null" >
+                #{od_no,jdbcType=VARCHAR},
+            </if>
+            <if test="od_mmid != null" >
+                #{od_mmid,jdbcType=INTEGER},
+            </if>
+            <if test="od_startdate != null" >
+                #{od_startdate,jdbcType=DATE},
+            </if>
+            <if test="od_enddate != null" >
+                #{od_enddate,jdbcType=DATE},
+            </if>
+            <if test="od_type != null" >
+                #{od_type,jdbcType=INTEGER},
+            </if>
+            <if test="od_comment != null" >
+                #{od_comment,jdbcType=VARCHAR},
+            </if>
+            <if test="od_changeDate != null" >
+                #{od_changeDate,jdbcType=VARCHAR},
+            </if>
+            <if test="od_userid != null" >
+                #{od_userid,jdbcType=VARCHAR}
+            </if>
+        </trim>
+    </insert>
+
+    <!-- 根据id更新一条培训信息 -->
+    <update id="updateYSOrderServiceLog" parameterType="com.ygj.yuemum.domain.order.YSOrderServiceLog" >
+        update ys_order_servicelog
+        <set >
+            <if test="od_enddate != null" >
+                od_enddate = #{od_enddate,jdbcType=DATE}
+            </if>
+        </set>
+        where od_no = #{od_no,jdbcType=VARCHAR}
+        and od_mmid = #{od_mmid,jdbcType=INTEGER}
+    </update>
+
+
+</mapper>

+ 10 - 0
src/main/resources/mybatis/mapper/pay/CustomerPayMapper.xml

@@ -29,6 +29,16 @@
         order by id desc
     </select>
 
+    <select id="checkCustomerPay" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.pay.CustomerPay" >
+        select
+        count(1)
+        from customer_pay
+        where cp_orderno = #{cp_orderno,jdbcType=VARCHAR}
+        and cp_ordertype = #{cp_ordertype,jdbcType=INTEGER}
+        and cp_orderstatus = #{cp_orderstatus,jdbcType=INTEGER}
+        order by id desc
+    </select>
+
     <select id="queryYSOrderPay" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.pay.CustomerPay" >
         select
         id,