|
@@ -1,25 +1,39 @@
|
|
|
package com.ygj.yuemum.service.order;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ygj.yuemum.component.Constant;
|
|
|
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.global.PackagesService;
|
|
|
import com.ygj.yuemum.service.maternitymatron.MmStockService;
|
|
|
+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.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
|
public class YSOrderReturnService {
|
|
|
+ public static final String extracttemplateid = Constant.MDJAPIURL;
|
|
|
+ @Autowired
|
|
|
+ private YSOrderDao YSOrderDao;
|
|
|
@Autowired
|
|
|
private YSOrderReturnDao ysOrderReturnDao;
|
|
|
@Autowired
|
|
|
private YSOrderDao ysOrderDao;
|
|
|
@Autowired
|
|
|
private MmStockService mmStockService;
|
|
|
+ @Autowired
|
|
|
+ private PackagesService packagesService;
|
|
|
|
|
|
public int insertYSOrderReturn (YSOrderReturn ysOrderReturn) {
|
|
|
try {
|
|
|
+ YSOrder ysOrder = YSOrderDao.selectByOdNo(ysOrderReturn.getOd_no());
|
|
|
ysOrderReturnDao.insertSelective(ysOrderReturn);
|
|
|
//更新订单状态为9
|
|
|
YSOrder returnYSOrder = new YSOrder();
|
|
@@ -32,6 +46,27 @@ public class YSOrderReturnService {
|
|
|
mmStock.setOrderno(ysOrderReturn.getOd_no());
|
|
|
mmStockService.deleteOrderStock(mmStock);
|
|
|
//删除介绍人
|
|
|
+ //调用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", 99);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
}catch (Exception ex) {
|
|
|
ex.printStackTrace();
|