Commit 7ab82873 authored by Quxl's avatar Quxl

x

parent f756b39e
package com.egolm.shop.api; package com.egolm.shop.api;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.FileUtil; import com.egolm.common.FileUtil;
import com.egolm.common.HttpUtil; import com.egolm.common.HttpUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.shop.api.service.OrderService; import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.common.utils.XmlUtil; import com.egolm.shop.common.utils.XmlUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@Api(tags={"订单相关接口"}) @Api(tags={"订单相关接口"})
@RestController @RestController
@RequestMapping("order") @RequestMapping("order")
public class OrderController { public class OrderController {
@Autowired @Autowired
private OrderService orderService; private OrderService orderService;
@Value("${wx.md5Key}") @Value("${wx.md5Key}")
private String md5Key; private String md5Key;
@ApiOperation("订单提交前检查") @ApiOperation("订单提交前检查")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="shopNO", dataType = "String", required = true, value = "店铺编号"), @ApiImplicitParam(paramType = "query", name="shopNO", dataType = "String", required = true, value = "店铺编号"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/check",method=RequestMethod.GET) @RequestMapping(value = "/check",method=RequestMethod.GET)
public String check(HttpServletRequest request) { public String check(HttpServletRequest request) {
String shopNO = request.getParameter("shopNO"); String shopNO = request.getParameter("shopNO");
String terminal = request.getParameter("terminal"); String terminal = request.getParameter("terminal");
String langID = request.getParameter("langID"); String langID = request.getParameter("langID");
Map<String,Object> params = new HashMap<String,Object>(); Map<String,Object> params = new HashMap<String,Object>();
params.put("shopNO", shopNO); params.put("shopNO", shopNO);
params.put("terminal", terminal); params.put("terminal", terminal);
params.put("langID", langID); params.put("langID", langID);
return orderService.orderCheck(params); return orderService.orderCheck(params);
} }
@ApiOperation("订单正式提交(JSON格式)") @ApiOperation("订单正式提交(JSON格式)")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"payTypeID\":1,\"addrID\":\"111111\",\"orderMemo\":\"备注\",\"couponNO\":\"\",\"couponTypeID\":\"\", \"bankType\": \"xxx\", 'bankAccount': 'xxx', 'bankAccountName': 'xxx', 'revBankType': 'xxx', 'revBankAccount': 'xxx', 'revBankAccountNo': 'xxx', 'formId': 'xxx', 'email': 'xxx', 'salesmanNo': 'xxx'}"), @ApiImplicitParam(paramType = "query", name="data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"payTypeID\":1,\"addrID\":\"111111\",\"orderMemo\":\"备注\",\"couponNO\":\"\",\"couponTypeID\":\"\", \"bankType\": \"xxx\", 'bankAccount': 'xxx', 'bankAccountName': 'xxx', 'revBankType': 'xxx', 'revBankAccount': 'xxx', 'revBankAccountNo': 'xxx', 'formId': 'xxx', 'email': 'xxx', 'salesmanNo': 'xxx'}"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/submit",method=RequestMethod.POST,produces = "application/json") @RequestMapping(value = "/submit",method=RequestMethod.POST,produces = "application/json")
public String submit(HttpServletRequest request) { public String submit(HttpServletRequest request) {
String reqJson = request.getParameter("data"); String reqJson = request.getParameter("data");
JSONObject jsonObj = JSONObject.parseObject(reqJson); JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("submit-------"+reqJson); System.out.println("submit-------"+reqJson);
return orderService.submit(jsonObj); return orderService.submit(jsonObj);
} }
@ApiOperation("获取主订单列表") @ApiOperation("获取主订单列表")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value = "店铺编号"), @ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value = "店铺编号"),
@ApiImplicitParam(paramType = "query", name="status", dataType = "int", required = true, value = "订单状态 0.全部 1. 待付款 2.待审核 3.待发货 4.已发货 5.已完成 6.已取消"), @ApiImplicitParam(paramType = "query", name="status", dataType = "int", required = true, value = "订单状态 0.全部 1. 待付款 2.待审核 3.待发货 4.已发货 5.已完成 6.已取消"),
@ApiImplicitParam(paramType = "query", name="orderType", dataType = "int", required = true, value = "订单类型 1正常 2门店装饰 3众筹", allowMultiple=true), @ApiImplicitParam(paramType = "query", name="orderType", dataType = "int", required = true, value = "订单类型 1正常 2门店装饰 3众筹", allowMultiple=true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = true, value = "第几页", defaultValue = "1"), @ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = true, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = true, value = "每页数量", defaultValue = "20"), @ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = true, value = "每页数量", defaultValue = "20"),
}) })
@RequestMapping(value = "/getOrderList",method=RequestMethod.GET) @RequestMapping(value = "/getOrderList",method=RequestMethod.GET)
public String getOrderList(String orgNo, String shopNo, Integer status, Integer[] orderType, String langID, Integer index, Integer limit) { public String getOrderList(String orgNo, String shopNo, Integer status, Integer[] orderType, String langID, Integer index, Integer limit) {
List<String> types = new ArrayList<String>(); List<String> types = new ArrayList<String>();
if(orderType != null) { if(orderType != null) {
for(Integer id : orderType) { for(Integer id : orderType) {
if(id != null) { if(id != null) {
types.add("" + id); types.add("" + id);
} }
} }
} }
Page page = new Page(); Page page = new Page();
page.setIndex(Long.valueOf(index)); page.setIndex(Long.valueOf(index));
page.setLimit(Long.valueOf(limit)); page.setLimit(Long.valueOf(limit));
page.setLimitKey("dOrderTime desc"); page.setLimitKey("dOrderTime desc");
return orderService.queryOrderList(orgNo, shopNo, status, types.toArray(new String[types.size()]), langID, page); return orderService.queryOrderList(orgNo, shopNo, status, types.toArray(new String[types.size()]), langID, page);
} }
@ApiOperation("获取主订单详情") @ApiOperation("获取主订单详情")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="salesOrderId", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="salesOrderId", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/getOrderDetail",method=RequestMethod.GET) @RequestMapping(value = "/getOrderDetail",method=RequestMethod.GET)
public String getOrderDetail(String salesOrderId, String langID, Integer index, Integer limit) { public String getOrderDetail(String salesOrderId, String langID, Integer index, Integer limit) {
return orderService.getOrderDetail(salesOrderId); return orderService.getOrderDetail(salesOrderId);
} }
@ApiOperation("获取子订单列表及详情") @ApiOperation("获取子订单列表及详情")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="salesOrderId", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="salesOrderId", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/getSubOrderList",method=RequestMethod.GET) @RequestMapping(value = "/getSubOrderList",method=RequestMethod.GET)
public String getSubOrderList(String salesOrderId) { public String getSubOrderList(String salesOrderId) {
return orderService.queryOrderDetailList(salesOrderId); return orderService.queryOrderDetailList(salesOrderId);
} }
@ApiOperation("获取子订单详情") @ApiOperation("获取子订单详情")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="subOrderID", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="subOrderID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/getSubOrderDetail",method=RequestMethod.GET) @RequestMapping(value = "/getSubOrderDetail",method=RequestMethod.GET)
public String getSubOrderDetail(String subOrderID) { public String getSubOrderDetail(String subOrderID) {
return orderService.getSubOrderDetail(subOrderID); return orderService.getSubOrderDetail(subOrderID);
} }
@ApiOperation("获取送货单详情") @ApiOperation("获取送货单详情")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="aocOrderID", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="aocOrderID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/getDeliverSubDetail",method=RequestMethod.GET) @RequestMapping(value = "/getDeliverSubDetail",method=RequestMethod.GET)
public String getDeliverSubDetail(String aocOrderID) { public String getDeliverSubDetail(String aocOrderID) {
List<Map<String, Object>> list = orderService.getDeliverSubDetail(aocOrderID); List<Map<String, Object>> list = orderService.getDeliverSubDetail(aocOrderID);
return Rjx.jsonOk().setData(list).toJson(); return Rjx.jsonOk().setData(list).toJson();
} }
@ApiOperation("小程序在线支付交易成功通知支付状态") @ApiOperation("小程序在线支付交易成功通知支付状态")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="nPayAmount", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="nPayAmount", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="sOpenID", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="sOpenID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="sTransTraceNO", dataType = "String", required = true, value="微信支付订单号"), @ApiImplicitParam(paramType = "query", name="sTransTraceNO", dataType = "String", required = true, value="微信支付订单号"),
@ApiImplicitParam(paramType = "query", name="sOutTradeNO", dataType = "String", required = true, value="商户支付单号"), @ApiImplicitParam(paramType = "query", name="sOutTradeNO", dataType = "String", required = true, value="商户支付单号"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/paySuccess",method=RequestMethod.GET) @RequestMapping(value = "/paySuccess",method=RequestMethod.GET)
public String paySuccess(BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO) { public String paySuccess(BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO) {
try { try {
String[] ary = sOutTradeNO.split("_", 2); String[] ary = sOutTradeNO.split("_", 2);
orderService.paySuccess(ary[0], nPayAmount, sOpenID, sTransTraceNO, sOutTradeNO, new Date()); orderService.paySuccess(ary[0], nPayAmount, sOpenID, sTransTraceNO, sOutTradeNO, new Date());
return Rjx.jsonOk().toJson(); return Rjx.jsonOk().toJson();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return Rjx.jsonErr().setMessage(e.getMessage()).toJson(); return Rjx.jsonErr().setMessage(e.getMessage()).toJson();
} }
} }
@ApiOperation("微信小程序支付回调") public static void main(String[] args) {
@RequestMapping(value = "/wxPayNotify",method= {RequestMethod.GET, RequestMethod.POST}) String md5Key = "FFRlbnBheS5jb20gQ0EgQ2VudGVyMRsw";
public String wxPayNotify(HttpServletRequest request) { String inputXmlString = "<xml><appid><![CDATA[wxb1ec171f1bac3429]]></appid>\r\n" +
Map<String, String> result = new HashMap<String, String>(); "<bank_type><![CDATA[OTHERS]]></bank_type>\r\n" +
try { "<cash_fee><![CDATA[11310]]></cash_fee>\r\n" +
InputStream instream = request.getInputStream(); "<fee_type><![CDATA[CNY]]></fee_type>\r\n" +
byte[] bytes = FileUtil.streamToBytes(instream); "<is_subscribe><![CDATA[N]]></is_subscribe>\r\n" +
String inputXmlString = new String(bytes, "utf-8"); "<mch_id><![CDATA[1559500511]]></mch_id>\r\n" +
System.out.println(inputXmlString); "<nonce_str><![CDATA[1902442834]]></nonce_str>\r\n" +
Map<String, String> sortMap = new TreeMap<String, String>(XmlUtil.toMap(inputXmlString)); "<openid><![CDATA[oqKxp5DEQx9TkuxAUq8aD6RxK3Zs]]></openid>\r\n" +
String sign = sortMap.remove("sign"); "<out_trade_no><![CDATA[15766669640469_964423]]></out_trade_no>\r\n" +
String queryString = HttpUtil.formatToQueryString(sortMap) + "&key=" + md5Key; "<result_code><![CDATA[SUCCESS]]></result_code>\r\n" +
String _sign = StringUtil.toMD5HexString(queryString).toUpperCase(); "<return_code><![CDATA[SUCCESS]]></return_code>\r\n" +
if(_sign.equals(sign)) { "<sign><![CDATA[D1D039E92700DBADAFBC8891DD312986]]></sign>\r\n" +
String result_code = sortMap.get("result_code"); "<time_end><![CDATA[20191218190304]]></time_end>\r\n" +
String return_code = sortMap.get("return_code"); "<total_fee>11310</total_fee>\r\n" +
if("SUCCESS".equals(return_code) && "SUCCESS".equals(result_code)) { "<trade_type><![CDATA[JSAPI]]></trade_type>\r\n" +
String out_trade_no = sortMap.get("out_trade_no"); "<transaction_id><![CDATA[4200000440201912185176717219]]></transaction_id>\r\n" +
String[] ary = out_trade_no.split("_", 2); "</xml>";
String transaction_id = sortMap.get("transaction_id");
String payEndTime = sortMap.get("time_end"); System.out.println(inputXmlString);
String openid = sortMap.get("openid"); Map<String, String> sortMap = new TreeMap<String, String>(XmlUtil.toMap(inputXmlString));
String total_fee = sortMap.get("total_fee"); String queryString = HttpUtil.formatToQueryString(sortMap) + "&key=" + md5Key;
String sSalesOrderID = ary[0]; String _sign = StringUtil.toMD5HexString(queryString).toUpperCase();
String sTransTraceNO = transaction_id; System.out.println(_sign);
String sOpenID = openid; System.out.println(sortMap.get("sign"));
String sOutTradeNO = out_trade_no; }
Date date = DateUtil.parse(payEndTime, "yyyyMMddHHmmss");
BigDecimal nPayAmount = new BigDecimal(total_fee);
orderService.paySuccess(sSalesOrderID, nPayAmount, sOpenID, sTransTraceNO, sOutTradeNO, date); @ApiOperation("微信小程序支付回调")
} @RequestMapping(value = "/wxPayNotify",method= {RequestMethod.GET, RequestMethod.POST})
result.put("return_code", "SUCCESS"); public String wxPayNotify(HttpServletRequest request) {
result.put("return_msg", "OK"); Map<String, String> result = new HashMap<String, String>();
} else { try {
result.put("return_code", "FAIL"); InputStream instream = request.getInputStream();
result.put("return_msg", "签名校验失败"); byte[] bytes = FileUtil.streamToBytes(instream);
} String inputXmlString = new String(bytes, "utf-8");
} catch (Throwable e) { System.out.println(inputXmlString);
e.printStackTrace(); Map<String, String> sortMap = new TreeMap<String, String>(XmlUtil.toMap(inputXmlString));
result.put("return_code", "FAIL"); // String sign = sortMap.remove("sign");
result.put("return_msg", e.getMessage()); // String queryString = HttpUtil.formatToQueryString(sortMap) + "&key=" + md5Key;
} // String _sign = StringUtil.toMD5HexString(queryString).toUpperCase();
return XmlUtil.toXml(result); String result_code = sortMap.get("result_code");
} String return_code = sortMap.get("return_code");
if("SUCCESS".equals(return_code) && "SUCCESS".equals(result_code)) {
@Transactional String out_trade_no = sortMap.get("out_trade_no");
@ApiOperation("取消未付款订单") String[] ary = out_trade_no.split("_", 2);
@ApiImplicitParams({ String transaction_id = sortMap.get("transaction_id");
@ApiImplicitParam(paramType = "query", name="sSalesOrderID", dataType = "String", required = true), String payEndTime = sortMap.get("time_end");
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), String openid = sortMap.get("openid");
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), String total_fee = sortMap.get("total_fee");
}) String sSalesOrderID = ary[0];
@RequestMapping(value = "/cancelOrder",method=RequestMethod.GET) String sTransTraceNO = transaction_id;
public String cancelOrder(String sSalesOrderID) { String sOpenID = openid;
orderService.cancelOrder(sSalesOrderID); String sOutTradeNO = out_trade_no;
return Rjx.jsonOk().toJson(); Date date = DateUtil.parse(payEndTime, "yyyyMMddHHmmss");
} BigDecimal nPayAmount = new BigDecimal(total_fee);
orderService.paySuccess(sSalesOrderID, nPayAmount, sOpenID, sTransTraceNO, sOutTradeNO, date);
@ApiOperation("提交组合促销订单") }
@RequestMapping(value = "/submitByGroup",method=RequestMethod.GET) result.put("return_code", "SUCCESS");
@ApiImplicitParams({ result.put("return_msg", "OK");
@ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true, value="sOrgNO"), } catch (Throwable e) {
@ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value="店铺编号"), e.printStackTrace();
@ApiImplicitParam(paramType = "query", name="promoPaperNO", dataType = "String", required = true, value="活动编号"), result.put("return_code", "FAIL");
@ApiImplicitParam(paramType = "query", name="promoGroupNO", dataType = "String", required = true, value="组合编号"), result.put("return_msg", e.getMessage());
@ApiImplicitParam(paramType = "query", name="saleQty", dataType = "String", required = true, value="组合数量"), }
@ApiImplicitParam(paramType = "query", name="addrId", dataType = "String", required = true, value="地址ID"), return XmlUtil.toXml(result);
@ApiImplicitParam(paramType = "query", name="payTypeId", dataType = "String", required = true, value="支付类型: 1.货到付款 4.在线支付 2.线下转账"), }
@ApiImplicitParam(paramType = "query", name="salesmanNo", dataType = "String", required = true, value="业务员"),
@ApiImplicitParam(paramType = "query", name="formId", dataType = "String", required = true, value=""), @Transactional
@ApiImplicitParam(paramType = "query", name="bankType", dataType = "String", required = true, value="银行"), @ApiOperation("取消未付款订单")
@ApiImplicitParam(paramType = "query", name="bankAccount", dataType = "String", required = true, value="银行账号"), @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="bankAccountName", dataType = "String"), @ApiImplicitParam(paramType = "query", name="sSalesOrderID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="revBankType", dataType = "String"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name="revBankAccount", dataType = "String"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name="revBankAccountNo", dataType = "String"), })
@ApiImplicitParam(paramType = "query", name="memo", dataType = "String", required = true, value="备注"), @RequestMapping(value = "/cancelOrder",method=RequestMethod.GET)
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), public String cancelOrder(String sSalesOrderID) {
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), orderService.cancelOrder(sSalesOrderID);
}) return Rjx.jsonOk().toJson();
public String submitByGroup(String orgNo, String shopNo, String promoPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) { }
String sSalesOrderID = orderService.submitByGroup(orgNo, shopNo, promoPaperNO, promoGroupNO, saleQty, addrId, payTypeId, terminal, salesmanNo, formId, bankType, bankAccount, bankAccountName, revBankType, revBankAccount, revBankAccountNo, memo);
return Rjx.jsonOk().set("sSalesOrderID", sSalesOrderID).toJson(); @ApiOperation("提交组合促销订单")
} @RequestMapping(value = "/submitByGroup",method=RequestMethod.GET)
@ApiImplicitParams({
@ApiOperation("提交众筹订单") @ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true, value="sOrgNO"),
@RequestMapping(value = "/submitByZhc",method=RequestMethod.GET) @ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value="店铺编号"),
@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name="promoPaperNO", dataType = "String", required = true, value="活动编号"),
@ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true, value="sOrgNO"), @ApiImplicitParam(paramType = "query", name="promoGroupNO", dataType = "String", required = true, value="组合编号"),
@ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value="店铺编号"), @ApiImplicitParam(paramType = "query", name="saleQty", dataType = "String", required = true, value="组合数量"),
@ApiImplicitParam(paramType = "query", name="planId", dataType = "int", required = true, value="众筹计划ID"), @ApiImplicitParam(paramType = "query", name="addrId", dataType = "String", required = true, value="地址ID"),
@ApiImplicitParam(paramType = "query", name="saleQty", dataType = "String", required = true, value="购买数量"), @ApiImplicitParam(paramType = "query", name="payTypeId", dataType = "String", required = true, value="支付类型: 1.货到付款 4.在线支付 2.线下转账"),
@ApiImplicitParam(paramType = "query", name="addrId", dataType = "String", required = true, value="地址ID"), @ApiImplicitParam(paramType = "query", name="salesmanNo", dataType = "String", required = true, value="业务员"),
@ApiImplicitParam(paramType = "query", name="salesmanNo", dataType = "String", required = true, value="业务员"), @ApiImplicitParam(paramType = "query", name="formId", dataType = "String", required = true, value=""),
@ApiImplicitParam(paramType = "query", name="payTypeId", dataType = "String", required = true, value="支付类型: 1.货到付款 4.在线支付 2.线下转账"), @ApiImplicitParam(paramType = "query", name="bankType", dataType = "String", required = true, value="银行"),
@ApiImplicitParam(paramType = "query", name="formId", dataType = "String", required = true, value=""), @ApiImplicitParam(paramType = "query", name="bankAccount", dataType = "String", required = true, value="银行账号"),
@ApiImplicitParam(paramType = "query", name="bankType", dataType = "String", required = true, value="银行"), @ApiImplicitParam(paramType = "query", name="bankAccountName", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="bankAccount", dataType = "String", required = true, value="银行账号"), @ApiImplicitParam(paramType = "query", name="revBankType", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="bankAccountName", dataType = "String"), @ApiImplicitParam(paramType = "query", name="revBankAccount", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="revBankType", dataType = "String"), @ApiImplicitParam(paramType = "query", name="revBankAccountNo", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="revBankAccount", dataType = "String"), @ApiImplicitParam(paramType = "query", name="memo", dataType = "String", required = true, value="备注"),
@ApiImplicitParam(paramType = "query", name="revBankAccountNo", dataType = "String"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name="memo", dataType = "String", required = true, value="备注"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), })
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), public String submitByGroup(String orgNo, String shopNo, String promoPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
}) String sSalesOrderID = orderService.submitByGroup(orgNo, shopNo, promoPaperNO, promoGroupNO, saleQty, addrId, payTypeId, terminal, salesmanNo, formId, bankType, bankAccount, bankAccountName, revBankType, revBankAccount, revBankAccountNo, memo);
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) { return Rjx.jsonOk().set("sSalesOrderID", sSalesOrderID).toJson();
String sSalesOrderID = orderService.submitByZhc(orgNo, shopNo, planId, saleQty, addrId, payTypeId, terminal, salesmanNo, formId, bankType, bankAccount, bankAccountName, revBankType, revBankAccount, revBankAccountNo, memo); }
return Rjx.jsonOk().set("sSalesOrderID", sSalesOrderID).toJson();
} @ApiOperation("提交众筹订单")
@RequestMapping(value = "/submitByZhc",method=RequestMethod.GET)
@ApiOperation("提交门店装饰订单") @ApiImplicitParams({
@RequestMapping(value = "/submitByMdzs",method=RequestMethod.GET) @ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true, value="sOrgNO"),
@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value="店铺编号"),
@ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true, value="sOrgNO"), @ApiImplicitParam(paramType = "query", name="planId", dataType = "int", required = true, value="众筹计划ID"),
@ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value="店铺编号"), @ApiImplicitParam(paramType = "query", name="saleQty", dataType = "String", required = true, value="购买数量"),
@ApiImplicitParam(paramType = "query", name="contractNo", dataType = "string", required = true, value="经销商合同编号 sAgentContractNO"), @ApiImplicitParam(paramType = "query", name="addrId", dataType = "String", required = true, value="地址ID"),
@ApiImplicitParam(paramType = "query", name="goodsId", dataType = "int", required = true, value="商品ID"), @ApiImplicitParam(paramType = "query", name="salesmanNo", dataType = "String", required = true, value="业务员"),
@ApiImplicitParam(paramType = "query", name="saleQty", dataType = "String", required = true, value="购买数量"), @ApiImplicitParam(paramType = "query", name="payTypeId", dataType = "String", required = true, value="支付类型: 1.货到付款 4.在线支付 2.线下转账"),
@ApiImplicitParam(paramType = "query", name="addrId", dataType = "String", required = true, value="地址ID"), @ApiImplicitParam(paramType = "query", name="formId", dataType = "String", required = true, value=""),
@ApiImplicitParam(paramType = "query", name="email", dataType = "String", required = true, value="邮箱"), @ApiImplicitParam(paramType = "query", name="bankType", dataType = "String", required = true, value="银行"),
@ApiImplicitParam(paramType = "query", name="salesmanNo", dataType = "String", required = true, value="业务员"), @ApiImplicitParam(paramType = "query", name="bankAccount", dataType = "String", required = true, value="银行账号"),
@ApiImplicitParam(paramType = "query", name="payTypeId", dataType = "String", required = true, value="支付类型: 1.货到付款 4.在线支付 2.线下转账"), @ApiImplicitParam(paramType = "query", name="bankAccountName", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="formId", dataType = "String", required = true, value=""), @ApiImplicitParam(paramType = "query", name="revBankType", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="bankType", dataType = "String", required = true, value="银行"), @ApiImplicitParam(paramType = "query", name="revBankAccount", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="bankAccount", dataType = "String", required = true, value="银行账号"), @ApiImplicitParam(paramType = "query", name="revBankAccountNo", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="bankAccountName", dataType = "String"), @ApiImplicitParam(paramType = "query", name="memo", dataType = "String", required = true, value="备注"),
@ApiImplicitParam(paramType = "query", name="revBankType", dataType = "String"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name="revBankAccount", dataType = "String"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name="revBankAccountNo", dataType = "String"), })
@ApiImplicitParam(paramType = "query", name="memo", dataType = "String", required = true, value="备注"), public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), String sSalesOrderID = orderService.submitByZhc(orgNo, shopNo, planId, saleQty, addrId, payTypeId, terminal, salesmanNo, formId, bankType, bankAccount, bankAccountName, revBankType, revBankAccount, revBankAccountNo, memo);
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), return Rjx.jsonOk().set("sSalesOrderID", sSalesOrderID).toJson();
}) }
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
String sSalesOrderID = orderService.submitByMdzs(orgNo, shopNo, contractNo, goodsId, saleQty, addrId, email, payTypeId, terminal, salesmanNo, formId, bankType, bankAccount, bankAccountName, revBankType, revBankAccount, revBankAccountNo, memo); @ApiOperation("提交门店装饰订单")
return Rjx.jsonOk().set("sSalesOrderID", sSalesOrderID).toJson(); @RequestMapping(value = "/submitByMdzs",method=RequestMethod.GET)
} @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="orgNo", dataType = "String", required = true, value="sOrgNO"),
@ApiOperation("确认收货") @ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value="店铺编号"),
@RequestMapping(value = "/confirmReceipt",method=RequestMethod.GET) @ApiImplicitParam(paramType = "query", name="contractNo", dataType = "string", required = true, value="经销商合同编号 sAgentContractNO"),
@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", name="goodsId", dataType = "int", required = true, value="商品ID"),
@ApiImplicitParam(paramType = "query", name="custNo", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="saleQty", dataType = "String", required = true, value="购买数量"),
@ApiImplicitParam(paramType = "query", name="subOrderID", dataType = "String", required = true), @ApiImplicitParam(paramType = "query", name="addrId", dataType = "String", required = true, value="地址ID"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name="email", dataType = "String", required = true, value="邮箱"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name="salesmanNo", dataType = "String", required = true, value="业务员"),
}) @ApiImplicitParam(paramType = "query", name="payTypeId", dataType = "String", required = true, value="支付类型: 1.货到付款 4.在线支付 2.线下转账"),
public String confirmReceipt(String custNo, String subOrderID) { @ApiImplicitParam(paramType = "query", name="formId", dataType = "String", required = true, value=""),
orderService.confirmReceipt(custNo, subOrderID); @ApiImplicitParam(paramType = "query", name="bankType", dataType = "String", required = true, value="银行"),
return Rjx.jsonOk().toJson(); @ApiImplicitParam(paramType = "query", name="bankAccount", dataType = "String", required = true, value="银行账号"),
} @ApiImplicitParam(paramType = "query", name="bankAccountName", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="revBankType", dataType = "String"),
} @ApiImplicitParam(paramType = "query", name="revBankAccount", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="revBankAccountNo", dataType = "String"),
@ApiImplicitParam(paramType = "query", name="memo", dataType = "String", required = true, value="备注"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
})
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
String sSalesOrderID = orderService.submitByMdzs(orgNo, shopNo, contractNo, goodsId, saleQty, addrId, email, payTypeId, terminal, salesmanNo, formId, bankType, bankAccount, bankAccountName, revBankType, revBankAccount, revBankAccountNo, memo);
return Rjx.jsonOk().set("sSalesOrderID", sSalesOrderID).toJson();
}
@ApiOperation("确认收货")
@RequestMapping(value = "/confirmReceipt",method=RequestMethod.GET)
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="custNo", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name="subOrderID", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
})
public String confirmReceipt(String custNo, String subOrderID) {
orderService.confirmReceipt(custNo, subOrderID);
return Rjx.jsonOk().toJson();
}
}
package com.egolm.shop.api.service; package com.egolm.shop.api.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
public interface OrderService { public interface OrderService {
public String orderCheck(Map<String,Object> params); public String orderCheck(Map<String,Object> params);
public String submit(JSONObject submitObj); public String submit(JSONObject submitObj);
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page); public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page);
public String queryOrderDetailList(String salesOrderId); public String queryOrderDetailList(String salesOrderId);
public String getOrderDetail(String salesOrderId); public String getOrderDetail(String salesOrderId);
public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime); public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime);
public String getSubOrderDetail(String subOrderID); public String getSubOrderDetail(String subOrderID);
public void cancelOrder(String sSalesOrderID); public void cancelOrder(String sSalesOrderID);
public String submitByGroup(String orgNo, String shopNo, String prompPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo); public String submitByGroup(String orgNo, String shopNo, String prompPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo); public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo); public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public void confirmReceipt(String custNo, String subOrderID); public void confirmReceipt(String custNo, String subOrderID);
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID); public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID);
} }
package com.egolm.shop.api.service.impl; package com.egolm.shop.api.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.UncategorizedSQLException; import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.Util; import com.egolm.common.Util;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.common.jdbc.dialect.Dialect; import com.egolm.common.jdbc.dialect.Dialect;
import com.egolm.common.jdbc.dialect.SqlServerDialect; import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.common.jdbc.dialect.bean.Sql; import com.egolm.common.jdbc.dialect.bean.Sql;
import com.egolm.shop.api.service.OrderService; import com.egolm.shop.api.service.OrderService;
import com.egolm.shop.api.service.QiyeWxService; import com.egolm.shop.api.service.QiyeWxService;
import com.egolm.shop.api.service.QiyeWxService.WxMessage; import com.egolm.shop.api.service.QiyeWxService.WxMessage;
import com.egolm.shop.api.service.QiyeWxService.WxMessage.MiniprogramNotice; import com.egolm.shop.api.service.QiyeWxService.WxMessage.MiniprogramNotice;
import com.egolm.shop.bean.TSalesOrder; import com.egolm.shop.bean.TSalesOrder;
import com.egolm.shop.bean.TSalesOrderDtl; import com.egolm.shop.bean.TSalesOrderDtl;
import com.egolm.shop.common.XException; import com.egolm.shop.common.XException;
import com.egolm.shop.common.utils.I18NUtils; import com.egolm.shop.common.utils.I18NUtils;
@Service @Service
public class OrderServiceImpl implements OrderService { public class OrderServiceImpl implements OrderService {
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired @Autowired
QiyeWxService wxService; QiyeWxService wxService;
/** /**
* 订单检查 * 订单检查
* <p>Title: orderCheck</p> * <p>Title: orderCheck</p>
* <p>Description: </p> * <p>Description: </p>
* @param params * @param params
* @return * @return
* @see com.egolm.shop.api.service.oms.service.OrderService#orderCheck(java.util.Map) * @see com.egolm.shop.api.service.oms.service.OrderService#orderCheck(java.util.Map)
*/ */
public String orderCheck(Map<String,Object> params) { public String orderCheck(Map<String,Object> params) {
jdbcTemplate.setDialect(new SqlServerDialect()); jdbcTemplate.setDialect(new SqlServerDialect());
String LangID = params.get("langID")+""; String LangID = params.get("langID")+"";
try { try {
Rjx rjx; Rjx rjx;
String shopNO = params.get("shopNO")+""; String shopNO = params.get("shopNO")+"";
String terminal = params.get("terminal")+""; String terminal = params.get("terminal")+"";
String sql="exec up_NewCreateCartTempItem '"+shopNO+"','"+terminal+"' "; String sql="exec up_NewCreateCartTempItem '"+shopNO+"','"+terminal+"' ";
List<Map<String ,Object>> resultMap=jdbcTemplate.executeMutil(sql).getDatas().get(0); List<Map<String ,Object>> resultMap=jdbcTemplate.executeMutil(sql).getDatas().get(0);
System.out.println(sql); System.out.println(sql);
if (Util.objTo(resultMap.get(0).get("Status"), Integer.class) == 0 && Util.objTo(resultMap.get(resultMap.size()-1).get("Status"), Integer.class) == 0) { if (Util.objTo(resultMap.get(0).get("Status"), Integer.class) == 0 && Util.objTo(resultMap.get(resultMap.size()-1).get("Status"), Integer.class) == 0) {
rjx = Rjx.jsonOk(); rjx = Rjx.jsonOk();
rjx.setData(resultMap); rjx.setData(resultMap);
} else { } else {
rjx = Rjx.jsonErr(); Map<String, Object> lastest = resultMap.get(resultMap.size() - 1);
} rjx = Rjx.jsonErr().setMessage((String)lastest.get("ErrorMsg"));
return rjx.toJson(); }
} catch(UncategorizedSQLException se) { return rjx.toJson();
String errorFullMsg = se.getMessage(); } catch(UncategorizedSQLException se) {
String key = "com.microsoft.sqlserver.jdbc.SQLServerException:"; String errorFullMsg = se.getMessage();
String errorSubMsg = errorFullMsg.substring(errorFullMsg.lastIndexOf(key)+key.length(), errorFullMsg.length()); String key = "com.microsoft.sqlserver.jdbc.SQLServerException:";
System.out.println(errorFullMsg); String errorSubMsg = errorFullMsg.substring(errorFullMsg.lastIndexOf(key)+key.length(), errorFullMsg.length());
System.out.println(errorSubMsg); System.out.println(errorFullMsg);
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Goods_error")).set("result", errorSubMsg).toJson(); System.out.println(errorSubMsg);
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Goods_error")).set("result", errorSubMsg).toJson();
}catch (Exception e) {
System.out.println("e...."+e.getMessage()); }catch (Exception e) {
e.printStackTrace(); System.out.println("e...."+e.getMessage());
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Goods_failure")).toJson(); e.printStackTrace();
} return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Goods_failure")).toJson();
} }
}
/**
* /**
* @Title: submit *
* @Description: 提交订单 * @Title: submit
* @param: @param submitObj * @Description: 提交订单
* @param: @return * @param: @param submitObj
* @return: String * @param: @return
* @throws * @return: String
*/ * @throws
public String submit(JSONObject submitObj) { */
jdbcTemplate.setDialect(new SqlServerDialect()); public String submit(JSONObject submitObj) {
String LangID=""+submitObj.get("langID"); jdbcTemplate.setDialect(new SqlServerDialect());
try { String LangID=""+submitObj.get("langID");
String shopNO=""+submitObj.get("shopNO"); try {
String payID=""+submitObj.get("payTypeID"); String shopNO=""+submitObj.get("shopNO");
String terminalTypeID=""+submitObj.get("terminal"); String payID=""+submitObj.get("payTypeID");
String addrID=""+submitObj.get("addrID"); String terminalTypeID=""+submitObj.get("terminal");
String orderMemo=""+submitObj.get("orderMemo"); String addrID=""+submitObj.get("addrID");
String couponNO=""+submitObj.get("couponNO"); String orderMemo=""+submitObj.get("orderMemo");
String couponTypeID=""+submitObj.get("couponTypeID"); String couponNO=""+submitObj.get("couponNO");
String formId = submitObj.getString("formId"); String couponTypeID=""+submitObj.get("couponTypeID");
String bankType = submitObj.getString("bankType"); String formId = submitObj.getString("formId");
String bankAccount = submitObj.getString("bankAccount"); String bankType = submitObj.getString("bankType");
String bankAccountName = submitObj.getString("bankAccountName"); String bankAccount = submitObj.getString("bankAccount");
String revBankType = submitObj.getString("revBankType"); String bankAccountName = submitObj.getString("bankAccountName");
String revBankAccount = submitObj.getString("revBankAccount"); String revBankType = submitObj.getString("revBankType");
String revBankAccountNo = submitObj.getString("revBankAccountNo"); String revBankAccount = submitObj.getString("revBankAccount");
String email = submitObj.getString("email"); String revBankAccountNo = submitObj.getString("revBankAccountNo");
String salesmanNo = submitObj.getString("salesmanNo"); String email = submitObj.getString("email");
bankAccountName = StringUtil.isBlank(bankAccountName) ? "" : bankAccountName; String salesmanNo = submitObj.getString("salesmanNo");
revBankType = StringUtil.isBlank(revBankType) ? "" : revBankType; bankAccountName = StringUtil.isBlank(bankAccountName) ? "" : bankAccountName;
revBankAccount = StringUtil.isBlank(revBankAccount) ? "" : revBankAccount; revBankType = StringUtil.isBlank(revBankType) ? "" : revBankType;
revBankAccountNo = StringUtil.isBlank(revBankAccountNo) ? "" : revBankAccountNo; revBankAccount = StringUtil.isBlank(revBankAccount) ? "" : revBankAccount;
revBankAccountNo = StringUtil.isBlank(revBankAccountNo) ? "" : revBankAccountNo;
String sql = "exec up_NewCreatetSalesOrder '" + shopNO + "',null, '" + payID + "', '" + terminalTypeID + "', '" + addrID + "', '" + orderMemo + "', '" + couponNO + "','" + couponTypeID + "', '', '1', '" + (bankType == null ? "" : bankType) + "', '" + (bankAccount == null ? "" : bankAccount) + "', '" + bankAccountName + "', '" + revBankType + "', '" + revBankAccount + "', '" + revBankAccountNo + "'";
List<Map<String, Object>> commitMap = jdbcTemplate.executeMutil(sql).getDatas().get(0); String sql = "exec up_NewCreatetSalesOrder '" + shopNO + "',null, '" + payID + "', '" + terminalTypeID + "', '" + addrID + "', '" + orderMemo + "', '" + couponNO + "','" + couponTypeID + "', '', '1', '" + (bankType == null ? "" : bankType) + "', '" + (bankAccount == null ? "" : bankAccount) + "', '" + bankAccountName + "', '" + revBankType + "', '" + revBankAccount + "', '" + revBankAccountNo + "'";
if (commitMap != null && commitMap.size() > 0 && commitMap.get(0) != null && Util.objTo(commitMap.get(0).get("Status"), Integer.class) == 0 && Util.objTo(commitMap.get(commitMap.size()-1).get("Status"), Integer.class) == 0) { List<Map<String, Object>> commitMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
String sSalesOrderID = (String)commitMap.get(0).get("SalesOrderID"); if (commitMap != null && commitMap.size() > 0 && commitMap.get(0) != null && Util.objTo(commitMap.get(0).get("Status"), Integer.class) == 0 && Util.objTo(commitMap.get(commitMap.size()-1).get("Status"), Integer.class) == 0) {
jdbcTemplate.update("update tSalesOrder set sFormID = ?, sEmail = ?, sSalesmanNO = ? where sSalesOrderID = ?", formId, email, salesmanNo, sSalesOrderID); String sSalesOrderID = (String)commitMap.get(0).get("SalesOrderID");
this.sendWxMessage(sSalesOrderID); jdbcTemplate.update("update tSalesOrder set sFormID = ?, sEmail = ?, sSalesmanNO = ? where sSalesOrderID = ?", formId, email, salesmanNo, sSalesOrderID);
return Rjx.jsonOk().setData(commitMap).toJson(); this.sendWxMessage(sSalesOrderID);
} else { return Rjx.jsonOk().setData(commitMap).toJson();
String errorMsg = ""; } else {
if(commitMap.size()>1){ String errorMsg = "";
errorMsg = (String)commitMap.get(0).get("StatusName")+";"+(String)commitMap.get(1).get("StatusName"); if(commitMap.size()>1){
}else{ errorMsg = (String)commitMap.get(0).get("StatusName")+";"+(String)commitMap.get(1).get("StatusName");
errorMsg = (String)commitMap.get(0).get("StatusName"); }else{
} errorMsg = (String)commitMap.get(0).get("StatusName");
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Order_failure")).set("errorMsg", errorMsg).toJson(); }
} return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Order_failure")).set("errorMsg", errorMsg).setData(commitMap).toJson();
} catch (Exception e) { }
e.printStackTrace(); } catch (Exception e) {
return Rjx.jsonErr().set("errorMsg", e.getMessage()).setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Order_error")).toJson(); e.printStackTrace();
} return Rjx.jsonErr().set("errorMsg", e.getMessage()).setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Order_error")).toJson();
} }
}
@Override
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page) { @Override
if(status == null) { public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page) {
status = 0; if(status == null) {
} status = 0;
//订单状态 0.全部 1. 待付款 2.待审核 3.待发货 4.已发货 5.已完成 6.已取消 }
String sql = "select * from tSalesOrder where sShopNO = '" + shopNo + "' and sOrgNO = '" + orgNo + "'"; //订单状态 0.全部 1. 待付款 2.待审核 3.待发货 4.已发货 5.已完成 6.已取消
if(status == 0) { String sql = "select * from tSalesOrder where sShopNO = '" + shopNo + "' and sOrgNO = '" + orgNo + "'";
sql += ""; if(status == 0) {
} else if(status == 1) { sql += "";
sql += " and sSalesOrderPayTypeID = '4' and nOrderStatus = 0"; } else if(status == 1) {
} else if(status == 2) { sql += " and sSalesOrderPayTypeID = '4' and nOrderStatus = 0";
sql += " and ((sSalesOrderPayTypeID = '2' and nOrderStatus = 0) or (sSalesOrderPayTypeID = '4' and nOrderStatus&37 = 32))"; } else if(status == 2) {
} else if(status == 3) { sql += " and ((sSalesOrderPayTypeID = '2' and nOrderStatus = 0) or (sSalesOrderPayTypeID = '4' and nOrderStatus&37 = 32))";
sql += " and nOrderStatus&29 = 4"; } else if(status == 3) {
} else if(status == 4) { sql += " and nOrderStatus&29 = 4";
sql += " and nOrderStatus&129 = 128"; } else if(status == 4) {
} else if(status == 5) { sql += " and nOrderStatus&129 = 128";
sql += " and nOrderStatus&17 = 16"; } else if(status == 5) {
} else if(status == 6) { sql += " and nOrderStatus&17 = 16";
sql += " and nOrderStatus&1 = 1"; } else if(status == 6) {
} else { sql += " and nOrderStatus&1 = 1";
throw new XException("订单状态不存在"); } else {
} throw new XException("订单状态不存在");
if(orderType != null && orderType.length > 0) { }
sql += " and sB2BOrderTypeID in (" + StringUtil.join("', '", "'", "'", "", orderType) + ")"; if(orderType != null && orderType.length > 0) {
} sql += " and sB2BOrderTypeID in (" + StringUtil.join("', '", "'", "'", "", orderType) + ")";
List<Map<String, Object>> orderList = jdbcTemplate.limit(sql, page); }
if(orderList.size() > 0) { List<Map<String, Object>> orderList = jdbcTemplate.limit(sql, page);
List<String> orderIds = orderList.stream().map(o-> (String)o.get("sSalesOrderID")).collect(Collectors.toList()); if(orderList.size() > 0) {
String sql2 = "select sod.*, agp.sURL from tSalesOrderDtl sod left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 where sod.sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")"; List<String> orderIds = orderList.stream().map(o-> (String)o.get("sSalesOrderID")).collect(Collectors.toList());
List<Map<String, Object>> orderDtlList = jdbcTemplate.queryForList(sql2); String sql2 = "select sod.*, agp.sURL from tSalesOrderDtl sod left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 where sod.sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")";
Map<String, List<Map<String, Object>>> dtlML = Util.listToML(orderDtlList, "sSalesOrderID"); List<Map<String, Object>> orderDtlList = jdbcTemplate.queryForList(sql2);
for(Map<String, Object> orderMap : orderList) { Map<String, List<Map<String, Object>>> dtlML = Util.listToML(orderDtlList, "sSalesOrderID");
String sSalesOrderID = (String)orderMap.get("sSalesOrderID"); for(Map<String, Object> orderMap : orderList) {
List<Map<String, Object>> dtlList = dtlML.get(sSalesOrderID); String sSalesOrderID = (String)orderMap.get("sSalesOrderID");
orderMap.put("list", dtlList); List<Map<String, Object>> dtlList = dtlML.get(sSalesOrderID);
} orderMap.put("list", dtlList);
String sql3 = "select * from tSalesOrderSub where sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")"; }
List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql3); String sql3 = "select * from tSalesOrderSub where sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")";
if(subList.size() > 0) { List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql3);
List<String> subIds = subList.stream().map(o-> (String)o.get("sSubOrderID")).collect(Collectors.toList()); if(subList.size() > 0) {
String sql4 = "select sosd.*, agp.sURL from tSalesOrderSubDtl sosd left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")"; List<String> subIds = subList.stream().map(o-> (String)o.get("sSubOrderID")).collect(Collectors.toList());
List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql4); String sql4 = "select sosd.*, agp.sURL from tSalesOrderSubDtl sosd left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSubOrderID"); List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql4);
for(Map<String, Object> subMap : subList) { Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSubOrderID");
String sSubOrderID = (String)subMap.get("sSubOrderID"); for(Map<String, Object> subMap : subList) {
List<Map<String, Object>> dtlList = subDtlML.get(sSubOrderID); String sSubOrderID = (String)subMap.get("sSubOrderID");
subMap.put("list", dtlList); List<Map<String, Object>> dtlList = subDtlML.get(sSubOrderID);
} subMap.put("list", dtlList);
} }
Map<String, List<Map<String, Object>>> ml = Util.listToML(subList, "sSalesOrderID"); }
for(Map<String, Object> orderMap : orderList) { Map<String, List<Map<String, Object>>> ml = Util.listToML(subList, "sSalesOrderID");
String sSalesOrderID = (String)orderMap.get("sSalesOrderID"); for(Map<String, Object> orderMap : orderList) {
List<Map<String, Object>> subListItem = ml.get(sSalesOrderID); String sSalesOrderID = (String)orderMap.get("sSalesOrderID");
orderMap.put("subList", subListItem == null ? new Object[0] : subListItem); List<Map<String, Object>> subListItem = ml.get(sSalesOrderID);
} orderMap.put("subList", subListItem == null ? new Object[0] : subListItem);
} }
return Rjx.jsonOk().set("list", orderList).toJson(); }
} return Rjx.jsonOk().set("list", orderList).toJson();
}
@Override
public String getOrderDetail(String salesOrderId) { @Override
Map<String, Object> orderMap = null; public String getOrderDetail(String salesOrderId) {
try { Map<String, Object> orderMap = null;
orderMap =jdbcTemplate.queryForMap("select * from tSalesOrder where sSalesOrderID = ?", salesOrderId); try {
} catch (EmptyResultDataAccessException e) { orderMap =jdbcTemplate.queryForMap("select * from tSalesOrder where sSalesOrderID = ?", salesOrderId);
throw new XException("订单编号错误或订单不存在"); } catch (EmptyResultDataAccessException e) {
} throw new XException("订单编号错误或订单不存在");
List<Map<String, Object>> orderDtlList = new ArrayList<Map<String, Object>>(); }
if(orderMap.size() > 0) { List<Map<String, Object>> orderDtlList = new ArrayList<Map<String, Object>>();
String sql2 = "select sod.*, agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID from tSalesOrderDtl sod left join tYWPromoMain pm on pm.sPromoPaperNO = sod.sPromoPaperNO left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 where sod.sSalesOrderID = ?"; if(orderMap.size() > 0) {
orderDtlList = jdbcTemplate.queryForList(sql2, salesOrderId); String sql2 = "select sod.*, agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID from tSalesOrderDtl sod left join tYWPromoMain pm on pm.sPromoPaperNO = sod.sPromoPaperNO left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 where sod.sSalesOrderID = ?";
} orderDtlList = jdbcTemplate.queryForList(sql2, salesOrderId);
String sqlPay = "" }
+ "select " String sqlPay = ""
+ "sum(case when sPayTypeID = '1' then nPayAmount else 0 end) nCashPayAmount, " + "select "
+ "sum(case when sPayTypeID = 'WxPay' then nPayAmount else 0 end) nWxPayAmount, " + "sum(case when sPayTypeID = '1' then nPayAmount else 0 end) nCashPayAmount, "
+ "sum(case when sPayTypeID = 'Coupon' then nPayAmount else 0 end) nCouponPayAmount, " + "sum(case when sPayTypeID = 'WxPay' then nPayAmount else 0 end) nWxPayAmount, "
+ "sum(nPayAmount) nTotalPayAmount " + "sum(case when sPayTypeID = 'Coupon' then nPayAmount else 0 end) nCouponPayAmount, "
+ "from tSalesOrderPay where sSalesOrderID = ?"; + "sum(nPayAmount) nTotalPayAmount "
Map<String, Object> payMap = jdbcTemplate.queryForMap(sqlPay, salesOrderId); + "from tSalesOrderPay where sSalesOrderID = ?";
payMap.put("nOrderTotalAmount", orderMap.get("nTotalSaleAmount")); Map<String, Object> payMap = jdbcTemplate.queryForMap(sqlPay, salesOrderId);
return Rjx.jsonOk().set("payData", payMap).set("list", orderMap).set("detail", orderDtlList).toJson(); payMap.put("nOrderTotalAmount", orderMap.get("nTotalSaleAmount"));
} return Rjx.jsonOk().set("payData", payMap).set("list", orderMap).set("detail", orderDtlList).toJson();
}
@Override
public String queryOrderDetailList(String salesOrderId) { @Override
String sql = "select * from tSalesOrderSub where sSalesOrderID = ?"; public String queryOrderDetailList(String salesOrderId) {
List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql, salesOrderId); String sql = "select * from tSalesOrderSub where sSalesOrderID = ?";
if(subList.size() > 0) { List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql, salesOrderId);
List<String> subIds = subList.stream().map(o-> (String)o.get("sSubOrderID")).collect(Collectors.toList()); if(subList.size() > 0) {
String sql2 = "select sosd.*, agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID from tSalesOrderSubDtl sosd left join tYWPromoMain pm on pm.sPromoPaperNO = sosd.sPromoPaperNO left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")"; List<String> subIds = subList.stream().map(o-> (String)o.get("sSubOrderID")).collect(Collectors.toList());
List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql2); String sql2 = "select sosd.*, agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID from tSalesOrderSubDtl sosd left join tYWPromoMain pm on pm.sPromoPaperNO = sosd.sPromoPaperNO left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSalesOrderID"); List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql2);
for(Map<String, Object> subMap : subList) { Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSalesOrderID");
String sSubOrderID = (String)subMap.get("sSubOrderID"); for(Map<String, Object> subMap : subList) {
List<Map<String, Object>> dtlList = subDtlML.get(sSubOrderID); String sSubOrderID = (String)subMap.get("sSubOrderID");
subMap.put("list", dtlList); List<Map<String, Object>> dtlList = subDtlML.get(sSubOrderID);
} subMap.put("list", dtlList);
} }
return Rjx.jsonOk().set("list", subList).toJson(); }
} return Rjx.jsonOk().set("list", subList).toJson();
}
@Override
@Transactional @Override
public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime) { @Transactional
Integer nIdx = jdbcTemplate.queryForInt("select ISNULL(MAX(nIdx),0) from tSalesOrderPay where sSalesOrderID = ?", sSalesOrderID); public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime) {
nPayAmount = nPayAmount.multiply(new BigDecimal(0.01)).setScale(2, BigDecimal.ROUND_HALF_UP); Integer nIdx = jdbcTemplate.queryForInt("select ISNULL(MAX(nIdx),0) from tSalesOrderPay where sSalesOrderID = ?", sSalesOrderID);
nPayAmount = nPayAmount.multiply(new BigDecimal(0.01)).setScale(2, BigDecimal.ROUND_HALF_UP);
Map<String, Object> map = new HashMap<String, Object>();
map.put("sSalesOrderID", sSalesOrderID); Map<String, Object> map = new HashMap<String, Object>();
map.put("nIdx", ++nIdx); map.put("sSalesOrderID", sSalesOrderID);
map.put("sPayTypeID", "WxPay"); map.put("nIdx", ++nIdx);
map.put("sPayType", "微信支付(小程序)"); map.put("sPayTypeID", "WxPay");
map.put("nPayAmount", nPayAmount); map.put("sPayType", "微信支付(小程序)");
map.put("sOutTradeNO", sOutTradeNO); map.put("nPayAmount", nPayAmount);
map.put("nPayDisAmount", BigDecimal.ZERO); map.put("sOutTradeNO", sOutTradeNO);
map.put("dPayDateTime", dPayDateTime); map.put("nPayDisAmount", BigDecimal.ZERO);
map.put("sTransTraceNO", sTransTraceNO); map.put("dPayDateTime", dPayDateTime);
map.put("sPayCardNO", sOpenID); map.put("sTransTraceNO", sTransTraceNO);
map.put("nTag", 0); map.put("sPayCardNO", sOpenID);
map.put("dLastUpdateTime", new Date()); map.put("nTag", 0);
Dialect dialect = jdbcTemplate.getDialect(); map.put("dLastUpdateTime", new Date());
Sql sqlDesc = dialect.argsInsert("tSalesOrderPay", map); Dialect dialect = jdbcTemplate.getDialect();
String sql = "if not exists (select * from tSalesOrderPay where sTransTraceNO = '" + sTransTraceNO + "') " + sqlDesc.getSql(); Sql sqlDesc = dialect.argsInsert("tSalesOrderPay", map);
jdbcTemplate.update(sql, sqlDesc.getArgs()); String sql = "if not exists (select * from tSalesOrderPay where sTransTraceNO = '" + sTransTraceNO + "') " + sqlDesc.getSql();
jdbcTemplate.update("update tSalesOrder set nOrderStatus = nOrderStatus|32 where sSalesOrderID = ?", sSalesOrderID); jdbcTemplate.update(sql, sqlDesc.getArgs());
try { jdbcTemplate.update("update tSalesOrder set nOrderStatus = nOrderStatus|32 where sSalesOrderID = ?", sSalesOrderID);
jdbcTemplate.executeMutil("exec Up_Ego_SplitOrderPrd '" + sSalesOrderID + "'"); try {
} catch (UncategorizedSQLException e) { jdbcTemplate.executeMutil("exec Up_Ego_SplitOrderPrd '" + sSalesOrderID + "'");
if(e.getMessage().contains("已拆单")) { } catch (UncategorizedSQLException e) {
return; if(e.getMessage().contains("已拆单")) {
} return;
throw e; }
} throw e;
} }
}
@Override
public String getSubOrderDetail(String subOrderID) { @Override
new ArrayList<Map<String, Object>>(); public String getSubOrderDetail(String subOrderID) {
Map<String, Object> subOrderMap = jdbcTemplate.queryForMap("" new ArrayList<Map<String, Object>>();
+ "select " Map<String, Object> subOrderMap = jdbcTemplate.queryForMap(""
+ "sos.*, " + "select "
+ "case when sos.nOrderStatus&145 = 144 then '16' when sos.nOrderStatus&145 = 128 then '8' when sos.nOrderStatus&145 = 0 then '4' when sos.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, " + "sos.*, "
+ "case when sos.nOrderStatus&145 = 144 then '已完成' when sos.nOrderStatus&145 = 128 then '配送中' when sos.nOrderStatus&145 = 0 then '待发货' when sos.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText " + "case when sos.nOrderStatus&145 = 144 then '16' when sos.nOrderStatus&145 = 128 then '8' when sos.nOrderStatus&145 = 0 then '4' when sos.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+ "from tSalesOrderSub sos where sos.sSubOrderID = ?", subOrderID); + "case when sos.nOrderStatus&145 = 144 then '已完成' when sos.nOrderStatus&145 = 128 then '配送中' when sos.nOrderStatus&145 = 0 then '待发货' when sos.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
Map<String, Object> orderMap = jdbcTemplate.queryForMap("" + "from tSalesOrderSub sos where sos.sSubOrderID = ?", subOrderID);
+ "select " Map<String, Object> orderMap = jdbcTemplate.queryForMap(""
+ "so.*, " + "select "
+ "case when so.nOrderStatus&145 = 144 then '16' when so.nOrderStatus&145 = 128 then '8' when so.nOrderStatus&145 = 0 then '4' when so.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, " + "so.*, "
+ "case when so.nOrderStatus&145 = 144 then '已完成' when so.nOrderStatus&145 = 128 then '配送中' when so.nOrderStatus&145 = 0 then '待发货' when so.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText " + "case when so.nOrderStatus&145 = 144 then '16' when so.nOrderStatus&145 = 128 then '8' when so.nOrderStatus&145 = 0 then '4' when so.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+ "from tSalesOrder so where so.sSalesOrderID = ?", subOrderMap.get("sSalesOrderID")); + "case when so.nOrderStatus&145 = 144 then '已完成' when so.nOrderStatus&145 = 128 then '配送中' when so.nOrderStatus&145 = 0 then '待发货' when so.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
String sql = "" + "from tSalesOrder so where so.sSalesOrderID = ?", subOrderMap.get("sSalesOrderID"));
+ "select " String sql = ""
+ "sosd.*, " + "select "
+ "agp.sURL, " + "sosd.*, "
+ "pm.sPromoTheme, " + "agp.sURL, "
+ "pm.sPromoActionType sPromoType, " + "pm.sPromoTheme, "
+ "pm.sPromoActionTypeID sPromoTypeID " + "pm.sPromoActionType sPromoType, "
+ "from tSalesOrderSubDtl sosd " + "pm.sPromoActionTypeID sPromoTypeID "
+ "left join tYWPromoMain pm on pm.sPromoPaperNO = sosd.sPromoPaperNO " + "from tSalesOrderSubDtl sosd "
+ "left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID = ?"; + "left join tYWPromoMain pm on pm.sPromoPaperNO = sosd.sPromoPaperNO "
List<Map<String, Object>> dtlList = jdbcTemplate.queryForList(sql, subOrderID); + "left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 where sosd.sSubOrderID = ?";
Map<String, Object> deliver = jdbcTemplate.queryForMap("SELECT sum(a.nNum) nTotalCount, sum(a.nPrice * a.nNum) nTotalAmount FROM tSalesOrderDeliverSubDtl a where a.sSubOrderID = ?", subOrderID); List<Map<String, Object>> dtlList = jdbcTemplate.queryForList(sql, subOrderID);
String sql3 = "select sSubOrderID, nOrderMoney, sAocOrderID, sAocOrderNumber, nOrderNum, nPickupNum, sExpressNO, sExpressName from tSalesOrderDeliverSub where nTag&1 = 0 and sSubOrderID = ?"; Map<String, Object> deliver = jdbcTemplate.queryForMap("SELECT sum(a.nNum) nTotalCount, sum(a.nPrice * a.nNum) nTotalAmount FROM tSalesOrderDeliverSubDtl a where a.sSubOrderID = ?", subOrderID);
List<Map<String, Object>> deliverSubList = jdbcTemplate.queryForList(sql3, subOrderID); String sql3 = "select sSubOrderID, nOrderMoney, sAocOrderID, sAocOrderNumber, nOrderNum, nPickupNum, sExpressNO, sExpressName from tSalesOrderDeliverSub where nTag&1 = 0 and sSubOrderID = ?";
return Rjx.jsonOk().set("deliver", deliver).set("deliverList", deliverSubList).set("order", orderMap).set("subOrder", subOrderMap).set("list", dtlList).toJson(); List<Map<String, Object>> deliverSubList = jdbcTemplate.queryForList(sql3, subOrderID);
} return Rjx.jsonOk().set("deliver", deliver).set("deliverList", deliverSubList).set("order", orderMap).set("subOrder", subOrderMap).set("list", dtlList).toJson();
}
@Override
public void cancelOrder(String sSalesOrderID) { @Override
jdbcTemplate.executeMutil("exec up_CancelledSalesOrder '" + sSalesOrderID + "'"); public void cancelOrder(String sSalesOrderID) {
} jdbcTemplate.executeMutil("exec up_CancelledSalesOrder '" + sSalesOrderID + "'");
}
@Override
@Transactional @Override
public String submitByGroup(String orgNo, String shopNo, String promoPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) { @Transactional
XException.assertNotBlank(orgNo, "OrgNO不能为空"); public String submitByGroup(String orgNo, String shopNo, String promoPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
XException.assertNotBlank(shopNo, "ShopNO不能为空"); XException.assertNotBlank(orgNo, "OrgNO不能为空");
XException.assertNotBlank(promoPaperNO, "PromoPaperNO不能为空"); XException.assertNotBlank(shopNo, "ShopNO不能为空");
XException.assertNotBlank(promoGroupNO, "PromoGroupNO不能为空"); XException.assertNotBlank(promoPaperNO, "PromoPaperNO不能为空");
XException.assertNotBlank(saleQty, "SaleQty不能为空"); XException.assertNotBlank(promoGroupNO, "PromoGroupNO不能为空");
XException.assertNotBlank(addrId, "AddrID不能为空"); XException.assertNotBlank(saleQty, "SaleQty不能为空");
XException.assertNotBlank(payTypeId, "PayTypeID不能为空"); XException.assertNotBlank(addrId, "AddrID不能为空");
XException.assertNotBlank(payTypeId, "PayTypeID不能为空");
String stockSql = "select og.sWarehouseNO, og.sAgentContractNO, og.nGoodsID, og.nStockQty, og.nLockedQty from tPromoRuleGoods prg, V_OrgGoods og where prg.sAgentContractNO = og.sAgentContractNO and prg.nGoodsID = og.nGoodsID and og.sOrgNO = ? and prg.sPromoPaperNO = ? and prg.sPromoGroupNO = ?";
String stockSql = "select og.sWarehouseNO, og.sAgentContractNO, og.nGoodsID, og.nStockQty, og.nLockedQty from tPromoRuleGoods prg, V_OrgGoods og where prg.sAgentContractNO = og.sAgentContractNO and prg.nGoodsID = og.nGoodsID and og.sOrgNO = ? and prg.sPromoPaperNO = ? and prg.sPromoGroupNO = ?";
List<Map<String, Object>> stockList = jdbcTemplate.queryForList(stockSql, orgNo, promoPaperNO, promoGroupNO);
Map<String, Map<String, Object>> stockMM = Util.listToMM(stockList, "_", "sAgentContractNO", "nGoodsID"); List<Map<String, Object>> stockList = jdbcTemplate.queryForList(stockSql, orgNo, promoPaperNO, promoGroupNO);
Map<String, Map<String, Object>> stockMM = Util.listToMM(stockList, "_", "sAgentContractNO", "nGoodsID");
Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ? and s.sOrgNO = ?", shopNo, orgNo);
String sCustTypeID = (String)custMap.get("sCustTypeID"); Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ? and s.sOrgNO = ?", shopNo, orgNo);
String sCustNO = (String)custMap.get("sCustNO"); String sCustTypeID = (String)custMap.get("sCustTypeID");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount); String sCustNO = (String)custMap.get("sCustNO");
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId); this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
List<String> address = new ArrayList<String>(); Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
address.add((String)addrMap.get("sProvince")); List<String> address = new ArrayList<String>();
address.add((String)addrMap.get("sCity")); address.add((String)addrMap.get("sProvince"));
address.add((String)addrMap.get("sDistrict")); address.add((String)addrMap.get("sCity"));
address.add((String)addrMap.get("sAddress")); address.add((String)addrMap.get("sDistrict"));
address = address.stream().filter(o -> o != null).collect(Collectors.toList()); address.add((String)addrMap.get("sAddress"));
String sAddress = StringUtil.join(" ", address); address = address.stream().filter(o -> o != null).collect(Collectors.toList());
String sMobile = (String)addrMap.get("sMobile"); String sAddress = StringUtil.join(" ", address);
String sEmail = (String)addrMap.get("sEmail"); String sMobile = (String)addrMap.get("sMobile");
String sPostalcode = (String)addrMap.get("sPostalcode"); String sEmail = (String)addrMap.get("sEmail");
String sContacts = (String)addrMap.get("sContacts"); String sPostalcode = (String)addrMap.get("sPostalcode");
String sContacts = (String)addrMap.get("sContacts");
String sql = "" +
"SELECT DISTINCT " + String sql = "" +
" GoodsID = b.nGoodsID, " + "SELECT DISTINCT " +
" GoodsDesc = ag.sGoodsDesc, " + " GoodsID = b.nGoodsID, " +
" AgentContractNO = ag.sAgentContractNO, " + " GoodsDesc = ag.sGoodsDesc, " +
" RealSalePrice = isnull(ap.nRealSalePrice, ag.nRealSalePrice), " + " AgentContractNO = ag.sAgentContractNO, " +
" AgentID = ag.nAgentID, " + " RealSalePrice = isnull(ap.nRealSalePrice, ag.nRealSalePrice), " +
" Barcode = ag.sMainBarcode, " + " AgentID = ag.nAgentID, " +
" MeetQty = b.nMeetQty, " + " Barcode = ag.sMainBarcode, " +
" Price = b.nPrice " + " MeetQty = b.nMeetQty, " +
" FROM tPromo a, tPromoRuleGoods b, tPromoCustBWList c, tAgent at, tAgentContractGoods ag " + " Price = b.nPrice " +
" LEFT JOIN tAgentCustTypePrice ap ON ap.sCustTypeID = c.sShopNO and ap.sAgentContractNO = ag.sAgentContractNO and ap.nGoodsID = ag.nGoodsID " + " FROM tPromo a, tPromoRuleGoods b, tPromoCustBWList c, tAgent at, tAgentContractGoods ag " +
" WHERE " + " LEFT JOIN tAgentCustTypePrice ap ON ap.sCustTypeID = c.sShopNO and ap.sAgentContractNO = ag.sAgentContractNO and ap.nGoodsID = ag.nGoodsID " +
" a.sPromoPaperNO = c.sPromoPaperNO " + " WHERE " +
" AND a.sPromoPaperNO = b.sPromoPaperNO " + " a.sPromoPaperNO = c.sPromoPaperNO " +
" AND b.sAgentContractNO = ag.sAgentContractNO " + " AND a.sPromoPaperNO = b.sPromoPaperNO " +
" AND ag.nAgentID = at.nAgentID " + " AND b.sAgentContractNO = ag.sAgentContractNO " +
" AND b.nGoodsID = ag.nGoodsID " + " AND ag.nAgentID = at.nAgentID " +
" AND a.sPromoActionTypeID = '3' " + " AND b.nGoodsID = ag.nGoodsID " +
" AND a.nTag&3=2 " + " AND a.sPromoActionTypeID = '3' " +
" AND b.nTag&3=2 " + " AND a.nTag&3=2 " +
" AND getdate() BETWEEN a.dPromoBeginDate AND a.dPromoEndDate " + " AND b.nTag&3=2 " +
" AND CASE WHEN nUseCycle&1 = 1 THEN '1,' ELSE '' END + " + " AND getdate() BETWEEN a.dPromoBeginDate AND a.dPromoEndDate " +
" CASE WHEN nUseCycle&2 = 2 THEN '2,' ELSE '' END + " + " AND CASE WHEN nUseCycle&1 = 1 THEN '1,' ELSE '' END + " +
" CASE WHEN nUseCycle&4 = 4 THEN '3,' ELSE '' END + " + " CASE WHEN nUseCycle&2 = 2 THEN '2,' ELSE '' END + " +
" CASE WHEN nUseCycle&8 = 8 THEN '4,' ELSE '' END + " + " CASE WHEN nUseCycle&4 = 4 THEN '3,' ELSE '' END + " +
" CASE WHEN nUseCycle&16 = 16 THEN '5,' ELSE '' END + " + " CASE WHEN nUseCycle&8 = 8 THEN '4,' ELSE '' END + " +
" CASE WHEN nUseCycle&32 = 32 THEN '6,' ELSE '' END + " + " CASE WHEN nUseCycle&16 = 16 THEN '5,' ELSE '' END + " +
" CASE WHEN nUseCycle&64 = 64 THEN '7' ELSE '' END LIKE '%' + convert(VARCHAR,datepart(weekday,getdate())) + '%' " + " CASE WHEN nUseCycle&32 = 32 THEN '6,' ELSE '' END + " +
" AND a.sPromoPaperNO = ? " + " CASE WHEN nUseCycle&64 = 64 THEN '7' ELSE '' END LIKE '%' + convert(VARCHAR,datepart(weekday,getdate())) + '%' " +
" AND b.sPromoGroupNO = ? " + " AND a.sPromoPaperNO = ? " +
" AND c.sShopNO = ? "; " AND b.sPromoGroupNO = ? " +
" AND c.sShopNO = ? ";
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(sql.replaceAll("\\s+", " "), promoPaperNO, promoGroupNO, sCustTypeID);
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(sql.replaceAll("\\s+", " "), promoPaperNO, promoGroupNO, sCustTypeID);
if(goodsList.size() == 0) {
throw new XException("对不起,您不能购买该礼包"); if(goodsList.size() == 0) {
} throw new XException("对不起,您不能购买该礼包");
}
BigDecimal Qty = BigDecimal.valueOf(saleQty);
BigDecimal nOrderTotalAmount = BigDecimal.ZERO; BigDecimal Qty = BigDecimal.valueOf(saleQty);
BigDecimal nPayTotalAmount = BigDecimal.ZERO; BigDecimal nOrderTotalAmount = BigDecimal.ZERO;
BigDecimal nTotalSaleQty = BigDecimal.ZERO; BigDecimal nPayTotalAmount = BigDecimal.ZERO;
BigDecimal nTotalSaleQty = BigDecimal.ZERO;
List<Object[]> batchArgs = new ArrayList<Object[]>();
for(Map<String, Object> gMap : goodsList) { List<Object[]> batchArgs = new ArrayList<Object[]>();
String GoodsDesc = (String)gMap.get("GoodsDesc"); for(Map<String, Object> gMap : goodsList) {
String sAgentContractNO = (String)gMap.get("AgentContractNO"); String GoodsDesc = (String)gMap.get("GoodsDesc");
Integer nGoodsID = ((Number)gMap.get("GoodsID")).intValue(); String sAgentContractNO = (String)gMap.get("AgentContractNO");
String key = sAgentContractNO + "_" + nGoodsID; Integer nGoodsID = ((Number)gMap.get("GoodsID")).intValue();
Map<String, Object> stockMap = stockMM.get(key); String key = sAgentContractNO + "_" + nGoodsID;
if(stockMap == null) { Map<String, Object> stockMap = stockMM.get(key);
throw new XException("活动商品库存异常"); if(stockMap == null) {
} throw new XException("活动商品库存异常");
BigDecimal nStockQty = (BigDecimal)stockMap.get("nStockQty"); }
BigDecimal nLockedQty = (BigDecimal)stockMap.get("nLockedQty"); BigDecimal nStockQty = (BigDecimal)stockMap.get("nStockQty");
BigDecimal MeetQty = (BigDecimal)gMap.get("MeetQty"); BigDecimal nLockedQty = (BigDecimal)stockMap.get("nLockedQty");
BigDecimal nTotalMeetQty = MeetQty.multiply(Qty); BigDecimal MeetQty = (BigDecimal)gMap.get("MeetQty");
if(nStockQty.subtract(nLockedQty).compareTo(nTotalMeetQty) < 0) { BigDecimal nTotalMeetQty = MeetQty.multiply(Qty);
throw new XException("商品[" + GoodsDesc + "]库存不足"); if(nStockQty.subtract(nLockedQty).compareTo(nTotalMeetQty) < 0) {
} throw new XException("商品[" + GoodsDesc + "]库存不足");
String sWarehouseNO = (String)stockMap.get("sWarehouseNO"); }
batchArgs.add(new Object[] {nTotalMeetQty, sAgentContractNO, nGoodsID, sWarehouseNO}); String sWarehouseNO = (String)stockMap.get("sWarehouseNO");
BigDecimal RealSalePrice = (BigDecimal)gMap.get("RealSalePrice"); batchArgs.add(new Object[] {nTotalMeetQty, sAgentContractNO, nGoodsID, sWarehouseNO});
BigDecimal Price = (BigDecimal)gMap.get("Price"); BigDecimal RealSalePrice = (BigDecimal)gMap.get("RealSalePrice");
BigDecimal TotalAmount = RealSalePrice.multiply(nTotalMeetQty); BigDecimal Price = (BigDecimal)gMap.get("Price");
BigDecimal PayAmount = Price.multiply(nTotalMeetQty); BigDecimal TotalAmount = RealSalePrice.multiply(nTotalMeetQty);
nOrderTotalAmount = nOrderTotalAmount.add(TotalAmount); BigDecimal PayAmount = Price.multiply(nTotalMeetQty);
nPayTotalAmount = nPayTotalAmount.add(PayAmount); nOrderTotalAmount = nOrderTotalAmount.add(TotalAmount);
nTotalSaleQty = nTotalSaleQty.add(nTotalMeetQty); nPayTotalAmount = nPayTotalAmount.add(PayAmount);
gMap.put("WarehouseNO", sWarehouseNO); nTotalSaleQty = nTotalSaleQty.add(nTotalMeetQty);
} gMap.put("WarehouseNO", sWarehouseNO);
jdbcTemplate.batchUpdate("update tAgentStockOnline set nLockedQty = (nLockedQty + ?) where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?", batchArgs); }
jdbcTemplate.batchUpdate("update tAgentStockOnline set nLockedQty = (nLockedQty + ?) where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?", batchArgs);
BigDecimal nTotalDisAmount = nOrderTotalAmount.subtract(nPayTotalAmount);
BigDecimal nTotalSaleAmount = nPayTotalAmount; BigDecimal nTotalDisAmount = nOrderTotalAmount.subtract(nPayTotalAmount);
TSalesOrder order = new TSalesOrder(); BigDecimal nTotalSaleAmount = nPayTotalAmount;
order.setsSalesOrderID(System.currentTimeMillis() + ""); TSalesOrder order = new TSalesOrder();
order.setdLastUpdateTime(new Date()); order.setsSalesOrderID(System.currentTimeMillis() + "");
order.setsCustNO(sCustNO); order.setdLastUpdateTime(new Date());
order.setsShopNO(shopNo); order.setsCustNO(sCustNO);
order.setsOrgNO(orgNo); order.setsShopNO(shopNo);
order.setdOrderDate(DateUtil.start(new Date())); order.setsOrgNO(orgNo);
order.setdOrderTime(new Date()); order.setdOrderDate(DateUtil.start(new Date()));
order.setdUpdate(new Date()); order.setdOrderTime(new Date());
order.setnOrderStatus(0); order.setdUpdate(new Date());
order.setsOrderStatusName("制单"); order.setnOrderStatus(0);
order.setnTotalDisAmount(nTotalDisAmount); order.setsOrderStatusName("制单");
order.setnTotalSaleAmount(nTotalSaleAmount); order.setnTotalDisAmount(nTotalDisAmount);
order.setsSalesmanNO(salesmanNo); order.setnTotalSaleAmount(nTotalSaleAmount);
order.setnTag(0); order.setsSalesmanNO(salesmanNo);
order.setnTotalSaleQty(nTotalSaleQty); order.setnTag(0);
order.setsAddress(sAddress); order.setnTotalSaleQty(nTotalSaleQty);
order.setsEmail(sEmail); order.setsAddress(sAddress);
order.setsMobile(sMobile); order.setsEmail(sEmail);
order.setsContacts(sContacts); order.setsMobile(sMobile);
order.setsPostalcode(sPostalcode); order.setsContacts(sContacts);
order.setnExpressFee(BigDecimal.ZERO); order.setsPostalcode(sPostalcode);
order.setsAddrID(addrId); order.setnExpressFee(BigDecimal.ZERO);
order.setsBankType(bankType); order.setsAddrID(addrId);
order.setsBankAccount(bankAccount); order.setsBankType(bankType);
order.setsBankAccountName(bankAccountName); order.setsBankAccount(bankAccount);
order.setsRevBankType(revBankType); order.setsBankAccountName(bankAccountName);
order.setsRevBankAccount(revBankAccount); order.setsRevBankType(revBankType);
order.setsRevBankAccountNO(revBankAccountNo); order.setsRevBankAccount(revBankAccount);
order.setsDeliveryType("送货"); order.setsRevBankAccountNO(revBankAccountNo);
order.setsDeliveryTypeID("1"); order.setsDeliveryType("送货");
order.setsSalesOrderPayTypeID(payTypeId); order.setsDeliveryTypeID("1");
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : ""))); order.setsSalesOrderPayTypeID(payTypeId);
order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal); order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal); order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal);
order.setsFormID(formId); order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal);
order.setsB2BOrderTypeID("4"); order.setsFormID(formId);
order.setsB2BOrderType("组合礼包订单"); order.setsB2BOrderTypeID("4");
order.setsOrderMemo(memo); order.setsB2BOrderType("组合礼包订单");
jdbcTemplate.save(order); order.setsOrderMemo(memo);
jdbcTemplate.save(order);
List<TSalesOrderDtl> list = new ArrayList<TSalesOrderDtl>();
Integer index = 1; List<TSalesOrderDtl> list = new ArrayList<TSalesOrderDtl>();
for(Map<String, Object> gMap : goodsList) { Integer index = 1;
TSalesOrderDtl dtl = new TSalesOrderDtl(); for(Map<String, Object> gMap : goodsList) {
String sSalesOrderID = order.getsSalesOrderID(); TSalesOrderDtl dtl = new TSalesOrderDtl();
Date dUpdate = new Date(); String sSalesOrderID = order.getsSalesOrderID();
BigDecimal MeetQty = (BigDecimal)gMap.get("MeetQty"); Date dUpdate = new Date();
Integer nAgentID = ((Number)gMap.get("AgentID")).intValue(); BigDecimal MeetQty = (BigDecimal)gMap.get("MeetQty");
BigDecimal RealSalePrice = (BigDecimal)gMap.get("RealSalePrice"); Integer nAgentID = ((Number)gMap.get("AgentID")).intValue();
BigDecimal Price = (BigDecimal)gMap.get("Price"); BigDecimal RealSalePrice = (BigDecimal)gMap.get("RealSalePrice");
BigDecimal nDisAmount = RealSalePrice.subtract(Price).multiply(MeetQty).multiply(Qty); BigDecimal Price = (BigDecimal)gMap.get("Price");
BigDecimal nSaleAmount = Price.multiply(MeetQty).multiply(Qty); BigDecimal nDisAmount = RealSalePrice.subtract(Price).multiply(MeetQty).multiply(Qty);
BigDecimal nSalePrice = Price; BigDecimal nSaleAmount = Price.multiply(MeetQty).multiply(Qty);
BigDecimal nSaleQty = MeetQty.multiply(Qty); BigDecimal nSalePrice = Price;
BigDecimal nExpressFee = BigDecimal.ZERO; BigDecimal nSaleQty = MeetQty.multiply(Qty);
Integer nGoodsID = ((Number)gMap.get("GoodsID")).intValue(); BigDecimal nExpressFee = BigDecimal.ZERO;
String sAgentContractNO = (String)gMap.get("AgentContractNO"); Integer nGoodsID = ((Number)gMap.get("GoodsID")).intValue();
String sBarcode = (String)gMap.get("Barcode"); String sAgentContractNO = (String)gMap.get("AgentContractNO");
String sGoodsDesc = (String)gMap.get("GoodsDesc"); String sBarcode = (String)gMap.get("Barcode");
String sWarehouseNO = (String)gMap.get("WarehouseNO"); String sGoodsDesc = (String)gMap.get("GoodsDesc");
dtl.setsSalesOrderID(sSalesOrderID); String sWarehouseNO = (String)gMap.get("WarehouseNO");
dtl.setdUpdate(dUpdate); dtl.setsSalesOrderID(sSalesOrderID);
dtl.setnAgentID(nAgentID); dtl.setdUpdate(dUpdate);
dtl.setnDisAmount(nDisAmount); dtl.setnAgentID(nAgentID);
dtl.setnExpressFee(nExpressFee); dtl.setnDisAmount(nDisAmount);
dtl.setnGoodsID(nGoodsID); dtl.setnExpressFee(nExpressFee);
dtl.setnIdx(index++); dtl.setnGoodsID(nGoodsID);
dtl.setnSaleAmount(nSaleAmount); dtl.setnIdx(index++);
dtl.setnSalePrice(nSalePrice); dtl.setnSaleAmount(nSaleAmount);
dtl.setnSaleQty(nSaleQty); dtl.setnSalePrice(nSalePrice);
dtl.setnTag(0); dtl.setnSaleQty(nSaleQty);
dtl.setsAgentContractNO(sAgentContractNO); dtl.setnTag(0);
dtl.setsBarcode(sBarcode); dtl.setsAgentContractNO(sAgentContractNO);
dtl.setsGoodsDesc(sGoodsDesc); dtl.setsBarcode(sBarcode);
dtl.setsMemo(memo); dtl.setsGoodsDesc(sGoodsDesc);
dtl.setsPromoActionType("组合折扣"); dtl.setsMemo(memo);
dtl.setsPromoActionTypeID("3"); dtl.setsPromoActionType("组合折扣");
dtl.setsPromoPaperNO(promoPaperNO); dtl.setsPromoActionTypeID("3");
dtl.setsSalesOrderID(sSalesOrderID); dtl.setsPromoPaperNO(promoPaperNO);
dtl.setsWarehouseNO(sWarehouseNO); dtl.setsSalesOrderID(sSalesOrderID);
dtl.setdLastUpdateTime(new Date()); dtl.setsWarehouseNO(sWarehouseNO);
list.add(dtl); dtl.setdLastUpdateTime(new Date());
} list.add(dtl);
jdbcTemplate.batchSave(list); }
this.sendWxMessage(order.getsSalesOrderID()); jdbcTemplate.batchSave(list);
return order.getsSalesOrderID(); this.sendWxMessage(order.getsSalesOrderID());
} return order.getsSalesOrderID();
}
@Override
@Transactional @Override
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) { @Transactional
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
XException.assertNotBlank(orgNo, "OrgNO不能为空");
XException.assertNotBlank(shopNo, "ShopNO不能为空"); XException.assertNotBlank(orgNo, "OrgNO不能为空");
XException.assertNotBlank(planId, "PlanID不能为空"); XException.assertNotBlank(shopNo, "ShopNO不能为空");
XException.assertNotBlank(saleQty, "SaleQty不能为空"); XException.assertNotBlank(planId, "PlanID不能为空");
XException.assertNotBlank(addrId, "AddrID不能为空"); XException.assertNotBlank(saleQty, "SaleQty不能为空");
XException.assertNotBlank(payTypeId, "PayTypeID不能为空"); XException.assertNotBlank(addrId, "AddrID不能为空");
XException.assertNotBlank(terminal, "Terminal不能为空"); XException.assertNotBlank(payTypeId, "PayTypeID不能为空");
XException.assertNotBlank(terminal, "Terminal不能为空");
BigDecimal Qty = BigDecimal.valueOf(saleQty);
Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo); BigDecimal Qty = BigDecimal.valueOf(saleQty);
String sCustNO = (String)custMap.get("sCustNO"); Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
this.saveOrderBankAccount(sCustNO, bankType, bankAccount); String sCustNO = (String)custMap.get("sCustNO");
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId); this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
List<String> address = new ArrayList<String>(); Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
address.add((String)addrMap.get("sProvince")); List<String> address = new ArrayList<String>();
address.add((String)addrMap.get("sCity")); address.add((String)addrMap.get("sProvince"));
address.add((String)addrMap.get("sDistrict")); address.add((String)addrMap.get("sCity"));
address.add((String)addrMap.get("sAddress")); address.add((String)addrMap.get("sDistrict"));
address = address.stream().filter(o -> o != null).collect(Collectors.toList()); address.add((String)addrMap.get("sAddress"));
String sAddress = StringUtil.join(" ", address); address = address.stream().filter(o -> o != null).collect(Collectors.toList());
String sMobile = (String)addrMap.get("sMobile"); String sAddress = StringUtil.join(" ", address);
String sEmail = (String)addrMap.get("sEmail"); String sMobile = (String)addrMap.get("sMobile");
String sPostalcode = (String)addrMap.get("sPostalcode"); String sEmail = (String)addrMap.get("sEmail");
String sContacts = (String)addrMap.get("sContacts"); String sPostalcode = (String)addrMap.get("sPostalcode");
String sContacts = (String)addrMap.get("sContacts");
String sqlplan = ""
+ "SELECT " + String sqlplan = ""
" t.*, " + + "SELECT " +
" og.nAgentID, " + " t.*, " +
" og.sWarehouseNO, " + " og.nAgentID, " +
" og.sGoodsDesc, " + " og.sWarehouseNO, " +
" og.sMainBarcode " + " og.sGoodsDesc, " +
"FROM " + " og.sMainBarcode " +
" ( " + "FROM " +
" SELECT " + " ( " +
" zp.*, " + " SELECT " +
" j.dStartDate, " + " zp.*, " +
" j.dEndDate, " + " j.dStartDate, " +
" j.nProjectAmount, " + " j.dEndDate, " +
" j.sProjectName, " + " j.nProjectAmount, " +
" j.sOrgNO " + " j.sProjectName, " +
" FROM " + " j.sOrgNO " +
" tZHCPlan zp, " + " FROM " +
" tZHCProject j " + " tZHCPlan zp, " +
" WHERE " + " tZHCProject j " +
" zp.nPlanID = ? " + " WHERE " +
" AND zp.nProjectID = j.nProjectID " + " zp.nPlanID = ? " +
" AND j.sOrgNO = ? " + " AND zp.nProjectID = j.nProjectID " +
" AND j.dStartDate <= getdate( ) " + " AND j.sOrgNO = ? " +
" AND j.dEndDate >= getdate( ) " + " AND j.dStartDate <= getdate( ) " +
" ) t " + " AND j.dEndDate >= getdate( ) " +
" LEFT JOIN V_OrgGoods og ON og.sOrgNO = t.sOrgNO " + " ) t " +
" AND og.sAgentContractNO = t.sAgentContractNO " + " LEFT JOIN V_OrgGoods og ON og.sOrgNO = t.sOrgNO " +
" AND og.nGoodsID = t.nGoodsID"; " AND og.sAgentContractNO = t.sAgentContractNO " +
" AND og.nGoodsID = t.nGoodsID";
Map<String, Object> gMap = jdbcTemplate.queryForMap(sqlplan.replaceAll("\\s+", " "), planId, orgNo);
BigDecimal nPrice = (BigDecimal)gMap.get("nPrice"); Map<String, Object> gMap = jdbcTemplate.queryForMap(sqlplan.replaceAll("\\s+", " "), planId, orgNo);
BigDecimal nTotalSaleAmount = nPrice.multiply(Qty); BigDecimal nPrice = (BigDecimal)gMap.get("nPrice");
BigDecimal nPlanStock = (BigDecimal)gMap.get("nPlanStock"); BigDecimal nTotalSaleAmount = nPrice.multiply(Qty);
Map<String, Object> planSum = jdbcTemplate.queryForMap("select sum(nTotalSaleQty) nOrderQty, sum(nTotalSaleAmount) nOrderAmount from tSalesOrder where nPlanID = ? and nOrderStatus&1 = 0", planId); BigDecimal nPlanStock = (BigDecimal)gMap.get("nPlanStock");
BigDecimal nOrderQty = (BigDecimal)planSum.get("nOrderQty"); Map<String, Object> planSum = jdbcTemplate.queryForMap("select sum(nTotalSaleQty) nOrderQty, sum(nTotalSaleAmount) nOrderAmount from tSalesOrder where nPlanID = ? and nOrderStatus&1 = 0", planId);
nOrderQty = nOrderQty == null ? BigDecimal.ZERO : nOrderQty; BigDecimal nOrderQty = (BigDecimal)planSum.get("nOrderQty");
nPlanStock = nPlanStock == null ? BigDecimal.ZERO : nPlanStock; nOrderQty = nOrderQty == null ? BigDecimal.ZERO : nOrderQty;
if(nOrderQty.compareTo(nPlanStock) == 0) { nPlanStock = nPlanStock == null ? BigDecimal.ZERO : nPlanStock;
throw new XException("该档众筹产品已售罄,请重新选择"); if(nOrderQty.compareTo(nPlanStock) == 0) {
} throw new XException("该档众筹产品已售罄,请重新选择");
if(nOrderQty.add(Qty).compareTo(nPlanStock) > 0) { }
throw new XException("该档众筹产品数量不足,请重新选择数量"); if(nOrderQty.add(Qty).compareTo(nPlanStock) > 0) {
} throw new XException("该档众筹产品数量不足,请重新选择数量");
TSalesOrder order = new TSalesOrder(); }
order.setnPlanID(planId); TSalesOrder order = new TSalesOrder();
order.setsSalesOrderID(System.currentTimeMillis() + ""); order.setnPlanID(planId);
order.setdLastUpdateTime(new Date()); order.setsSalesOrderID(System.currentTimeMillis() + "");
order.setsCustNO(sCustNO); order.setdLastUpdateTime(new Date());
order.setsShopNO(shopNo); order.setsCustNO(sCustNO);
order.setsOrgNO(orgNo); order.setsShopNO(shopNo);
order.setnTag(0); order.setsOrgNO(orgNo);
order.setdOrderDate(DateUtil.start(new Date())); order.setnTag(0);
order.setdOrderTime(new Date()); order.setdOrderDate(DateUtil.start(new Date()));
order.setdUpdate(new Date()); order.setdOrderTime(new Date());
order.setnOrderStatus(0); order.setdUpdate(new Date());
order.setsOrderStatusName("制单"); order.setnOrderStatus(0);
order.setnTotalDisAmount(BigDecimal.ZERO); order.setsOrderStatusName("制单");
order.setnTotalSaleAmount(nTotalSaleAmount); order.setnTotalDisAmount(BigDecimal.ZERO);
order.setnTotalSaleQty(Qty); order.setnTotalSaleAmount(nTotalSaleAmount);
order.setsAddress(sAddress); order.setnTotalSaleQty(Qty);
order.setsEmail(sEmail); order.setsAddress(sAddress);
order.setsMobile(sMobile); order.setsEmail(sEmail);
order.setsContacts(sContacts); order.setsMobile(sMobile);
order.setsPostalcode(sPostalcode); order.setsContacts(sContacts);
order.setsSalesmanNO(salesmanNo); order.setsPostalcode(sPostalcode);
order.setnExpressFee(BigDecimal.ZERO); order.setsSalesmanNO(salesmanNo);
order.setsAddrID(addrId); order.setnExpressFee(BigDecimal.ZERO);
order.setsBankType(bankType); order.setsAddrID(addrId);
order.setsBankAccount(bankAccount); order.setsBankType(bankType);
order.setsBankAccountName(bankAccountName); order.setsBankAccount(bankAccount);
order.setsRevBankType(revBankType); order.setsBankAccountName(bankAccountName);
order.setsRevBankAccount(revBankAccount); order.setsRevBankType(revBankType);
order.setsRevBankAccountNO(revBankAccountNo); order.setsRevBankAccount(revBankAccount);
order.setsDeliveryType("送货"); order.setsRevBankAccountNO(revBankAccountNo);
order.setsDeliveryTypeID("1"); order.setsDeliveryType("送货");
order.setsSalesOrderPayTypeID(payTypeId); order.setsDeliveryTypeID("1");
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : ""))); order.setsSalesOrderPayTypeID(payTypeId);
order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal); order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal); order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal);
order.setsFormID(formId); order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal);
order.setsB2BOrderTypeID("3"); order.setsFormID(formId);
order.setsB2BOrderType("众筹订单"); order.setsB2BOrderTypeID("3");
order.setsOrderMemo(memo); order.setsB2BOrderType("众筹订单");
jdbcTemplate.save(order); order.setsOrderMemo(memo);
jdbcTemplate.save(order);
TSalesOrderDtl dtl = new TSalesOrderDtl();
String sSalesOrderID = order.getsSalesOrderID(); TSalesOrderDtl dtl = new TSalesOrderDtl();
Date dUpdate = new Date(); String sSalesOrderID = order.getsSalesOrderID();
Integer nGoodsID = ((Number)gMap.get("nGoodsID")).intValue(); Date dUpdate = new Date();
String sAgentContractNO = (String)gMap.get("sAgentContractNO"); Integer nGoodsID = ((Number)gMap.get("nGoodsID")).intValue();
String sBarcode = (String)gMap.get("sMainBarcode"); String sAgentContractNO = (String)gMap.get("sAgentContractNO");
String sGoodsDesc = (String)gMap.get("sGoodsDesc"); String sBarcode = (String)gMap.get("sMainBarcode");
String sWarehouseNO = (String)gMap.get("sWarehouseNO"); String sGoodsDesc = (String)gMap.get("sGoodsDesc");
Integer nAgentID = ((Number)gMap.get("nAgentID")).intValue(); String sWarehouseNO = (String)gMap.get("sWarehouseNO");
dtl.setsSalesOrderID(sSalesOrderID); Integer nAgentID = ((Number)gMap.get("nAgentID")).intValue();
dtl.setdUpdate(dUpdate); dtl.setsSalesOrderID(sSalesOrderID);
dtl.setnAgentID(nAgentID); dtl.setdUpdate(dUpdate);
dtl.setnDisAmount(BigDecimal.ZERO); dtl.setnAgentID(nAgentID);
dtl.setnExpressFee(BigDecimal.ZERO); dtl.setnDisAmount(BigDecimal.ZERO);
dtl.setnGoodsID(nGoodsID); dtl.setnExpressFee(BigDecimal.ZERO);
dtl.setnIdx(1); dtl.setnGoodsID(nGoodsID);
dtl.setnSaleAmount(nTotalSaleAmount); dtl.setnIdx(1);
dtl.setnSalePrice(nPrice); dtl.setnSaleAmount(nTotalSaleAmount);
dtl.setnSaleQty(Qty); dtl.setnSalePrice(nPrice);
dtl.setnTag(0); dtl.setnSaleQty(Qty);
dtl.setsAgentContractNO(sAgentContractNO); dtl.setnTag(0);
dtl.setdLastUpdateTime(new Date()); dtl.setsAgentContractNO(sAgentContractNO);
dtl.setsBarcode(sBarcode); dtl.setdLastUpdateTime(new Date());
dtl.setsGoodsDesc(sGoodsDesc); dtl.setsBarcode(sBarcode);
dtl.setsMemo(memo); dtl.setsGoodsDesc(sGoodsDesc);
dtl.setsSalesOrderID(sSalesOrderID); dtl.setsMemo(memo);
dtl.setsWarehouseNO(sWarehouseNO); dtl.setsSalesOrderID(sSalesOrderID);
jdbcTemplate.save(dtl); dtl.setsWarehouseNO(sWarehouseNO);
jdbcTemplate.save(dtl);
{
Long nProjectID = jdbcTemplate.queryForLong("select nProjectID from tZHCPlan where nPlanID = ?", planId); {
String sql = "select count(so.sSalesOrderID) nSalePaperQty, isnull(sum(so.nTotalSaleQty), 0) nSaleQty, isnull(sum(so.nTotalSaleAmount), 0) nSaleAmount from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nTag&1 = 0 and so.nPlanID = p.nPlanID and p.nProjectID = ?"; Long nProjectID = jdbcTemplate.queryForLong("select nProjectID from tZHCPlan where nPlanID = ?", planId);
Map<String, Object> map = jdbcTemplate.queryForMap(sql, nProjectID); String sql = "select count(so.sSalesOrderID) nSalePaperQty, isnull(sum(so.nTotalSaleQty), 0) nSaleQty, isnull(sum(so.nTotalSaleAmount), 0) nSaleAmount from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nTag&1 = 0 and so.nPlanID = p.nPlanID and p.nProjectID = ?";
Integer nSalePaperQty = ((Number)map.get("nSalePaperQty")).intValue(); Map<String, Object> map = jdbcTemplate.queryForMap(sql, nProjectID);
BigDecimal nSaleQty = (BigDecimal)map.get("nSaleQty"); Integer nSalePaperQty = ((Number)map.get("nSalePaperQty")).intValue();
BigDecimal nSaleAmount = (BigDecimal)map.get("nSaleAmount"); BigDecimal nSaleQty = (BigDecimal)map.get("nSaleQty");
String sqlUpdate = "update tZHCProject set nSalePaperQty = ?, nSaleQty = ?, nSaleAmount = ? where nProjectID = ?"; BigDecimal nSaleAmount = (BigDecimal)map.get("nSaleAmount");
jdbcTemplate.executeUpdate(sqlUpdate, nSalePaperQty, nSaleQty, nSaleAmount, nProjectID); String sqlUpdate = "update tZHCProject set nSalePaperQty = ?, nSaleQty = ?, nSaleAmount = ? where nProjectID = ?";
} jdbcTemplate.executeUpdate(sqlUpdate, nSalePaperQty, nSaleQty, nSaleAmount, nProjectID);
this.sendWxMessage(order.getsSalesOrderID()); }
return order.getsSalesOrderID(); this.sendWxMessage(order.getsSalesOrderID());
} return order.getsSalesOrderID();
}
@Override
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) { @Override
XException.assertNotBlank(orgNo, "OrgNO不能为空"); public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
XException.assertNotBlank(shopNo, "ShopNO不能为空"); XException.assertNotBlank(orgNo, "OrgNO不能为空");
XException.assertNotBlank(contractNo, "ContractNO不能为空"); XException.assertNotBlank(shopNo, "ShopNO不能为空");
XException.assertNotBlank(goodsId, "GoodsID不能为空"); XException.assertNotBlank(contractNo, "ContractNO不能为空");
XException.assertNotBlank(saleQty, "SaleQty不能为空"); XException.assertNotBlank(goodsId, "GoodsID不能为空");
XException.assertNotBlank(addrId, "AddrID不能为空"); XException.assertNotBlank(saleQty, "SaleQty不能为空");
XException.assertNotBlank(payTypeId, "PayTypeID不能为空"); XException.assertNotBlank(addrId, "AddrID不能为空");
XException.assertNotBlank(terminal, "Terminal不能为空"); XException.assertNotBlank(payTypeId, "PayTypeID不能为空");
XException.assertNotBlank(terminal, "Terminal不能为空");
Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustTypeID = (String)custMap.get("sCustTypeID"); Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustNO = (String)custMap.get("sCustNO"); String sCustTypeID = (String)custMap.get("sCustTypeID");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount); String sCustNO = (String)custMap.get("sCustNO");
BigDecimal Qty = BigDecimal.valueOf(saleQty); this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId); BigDecimal Qty = BigDecimal.valueOf(saleQty);
List<String> address = new ArrayList<String>(); Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
address.add((String)addrMap.get("sProvince")); List<String> address = new ArrayList<String>();
address.add((String)addrMap.get("sCity")); address.add((String)addrMap.get("sProvince"));
address.add((String)addrMap.get("sDistrict")); address.add((String)addrMap.get("sCity"));
address.add((String)addrMap.get("sAddress")); address.add((String)addrMap.get("sDistrict"));
address = address.stream().filter(o -> o != null).collect(Collectors.toList()); address.add((String)addrMap.get("sAddress"));
String sAddress = StringUtil.join(" ", address); address = address.stream().filter(o -> o != null).collect(Collectors.toList());
String sMobile = (String)addrMap.get("sMobile"); String sAddress = StringUtil.join(" ", address);
String sPostalcode = (String)addrMap.get("sPostalcode"); String sMobile = (String)addrMap.get("sMobile");
String sContacts = (String)addrMap.get("sContacts"); String sPostalcode = (String)addrMap.get("sPostalcode");
String sContacts = (String)addrMap.get("sContacts");
String gSql = "select t.*, ap.nRealSalePrice nApSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = t.sAgentContractNO and ap.nGoodsID = t.nGoodsID where t.sOrgNO = ? and t.sAgentContractNO = ? and t.nGoodsID = ?";
Map<String, Object> gMap = jdbcTemplate.queryForMap(gSql, sCustTypeID, orgNo, contractNo, goodsId); String gSql = "select t.*, ap.nRealSalePrice nApSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = t.sAgentContractNO and ap.nGoodsID = t.nGoodsID where t.sOrgNO = ? and t.sAgentContractNO = ? and t.nGoodsID = ?";
BigDecimal nStockQty = (BigDecimal)gMap.get("nStockQty"); Map<String, Object> gMap = jdbcTemplate.queryForMap(gSql, sCustTypeID, orgNo, contractNo, goodsId);
BigDecimal nLockedQty = (BigDecimal)gMap.get("nLockedQty"); BigDecimal nStockQty = (BigDecimal)gMap.get("nStockQty");
BigDecimal stock = nStockQty.subtract(nLockedQty); BigDecimal nLockedQty = (BigDecimal)gMap.get("nLockedQty");
String sGoodsDesc = (String)gMap.get("sGoodsDesc"); BigDecimal stock = nStockQty.subtract(nLockedQty);
String sAgentContractNO = (String)gMap.get("sAgentContractNO"); String sGoodsDesc = (String)gMap.get("sGoodsDesc");
Integer nGoodsID = (Integer)gMap.get("nGoodsID"); String sAgentContractNO = (String)gMap.get("sAgentContractNO");
String sWarehouseNO = (String)gMap.get("sWarehouseNO"); Integer nGoodsID = (Integer)gMap.get("nGoodsID");
String sBarcode = (String)gMap.get("sMainBarcode"); String sWarehouseNO = (String)gMap.get("sWarehouseNO");
Integer nAgentID = ((Number)gMap.get("nAgentID")).intValue(); String sBarcode = (String)gMap.get("sMainBarcode");
if(stock.compareTo(Qty) < 0) { Integer nAgentID = ((Number)gMap.get("nAgentID")).intValue();
throw new XException("商品[" + sGoodsDesc + "]库存不足"); if(stock.compareTo(Qty) < 0) {
} else { throw new XException("商品[" + sGoodsDesc + "]库存不足");
String stockSql = "update tAgentStockOnline set nLockedQty = nLockedQty + ? where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?"; } else {
jdbcTemplate.update(stockSql, Qty, sAgentContractNO, nGoodsID, sWarehouseNO); String stockSql = "update tAgentStockOnline set nLockedQty = nLockedQty + ? where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?";
} jdbcTemplate.update(stockSql, Qty, sAgentContractNO, nGoodsID, sWarehouseNO);
}
BigDecimal nTotalSaleAmount = BigDecimal.ZERO;
BigDecimal nRealSalePrice = (BigDecimal)gMap.get("nApSalePrice"); BigDecimal nTotalSaleAmount = BigDecimal.ZERO;
if(nRealSalePrice == null) { BigDecimal nRealSalePrice = (BigDecimal)gMap.get("nApSalePrice");
nRealSalePrice = (BigDecimal)gMap.get("nRealSalePrice"); if(nRealSalePrice == null) {
} nRealSalePrice = (BigDecimal)gMap.get("nRealSalePrice");
nTotalSaleAmount = nTotalSaleAmount.add(nRealSalePrice.multiply(Qty)); }
nTotalSaleAmount = nTotalSaleAmount.add(nRealSalePrice.multiply(Qty));
TSalesOrder order = new TSalesOrder();
order.setsSalesOrderID(System.currentTimeMillis() + ""); TSalesOrder order = new TSalesOrder();
order.setdLastUpdateTime(new Date()); order.setsSalesOrderID(System.currentTimeMillis() + "");
order.setsCustNO(sCustNO); order.setdLastUpdateTime(new Date());
order.setsShopNO(shopNo); order.setsCustNO(sCustNO);
order.setsOrgNO(orgNo); order.setsShopNO(shopNo);
order.setnTag(0); order.setsOrgNO(orgNo);
order.setdOrderDate(DateUtil.start(new Date())); order.setnTag(0);
order.setdOrderTime(new Date()); order.setdOrderDate(DateUtil.start(new Date()));
order.setdUpdate(new Date()); order.setdOrderTime(new Date());
order.setsSalesmanNO(salesmanNo); order.setdUpdate(new Date());
order.setnOrderStatus(0); order.setsSalesmanNO(salesmanNo);
order.setsOrderStatusName("制单"); order.setnOrderStatus(0);
order.setnTotalDisAmount(BigDecimal.ZERO); order.setsOrderStatusName("制单");
order.setnTotalSaleAmount(nTotalSaleAmount); order.setnTotalDisAmount(BigDecimal.ZERO);
order.setnTotalSaleQty(Qty); order.setnTotalSaleAmount(nTotalSaleAmount);
order.setsAddress(sAddress); order.setnTotalSaleQty(Qty);
order.setsEmail(email); order.setsAddress(sAddress);
order.setsMobile(sMobile); order.setsEmail(email);
order.setsContacts(sContacts); order.setsMobile(sMobile);
order.setsPostalcode(sPostalcode); order.setsContacts(sContacts);
order.setnExpressFee(BigDecimal.ZERO); order.setsPostalcode(sPostalcode);
order.setsAddrID(addrId); order.setnExpressFee(BigDecimal.ZERO);
order.setsBankType(bankType); order.setsAddrID(addrId);
order.setsBankAccount(bankAccount); order.setsBankType(bankType);
order.setsBankAccountName(bankAccountName); order.setsBankAccount(bankAccount);
order.setsRevBankType(revBankType); order.setsBankAccountName(bankAccountName);
order.setsRevBankAccount(revBankAccount); order.setsRevBankType(revBankType);
order.setsRevBankAccountNO(revBankAccountNo); order.setsRevBankAccount(revBankAccount);
order.setsDeliveryType("送货"); order.setsRevBankAccountNO(revBankAccountNo);
order.setsDeliveryTypeID("1"); order.setsDeliveryType("送货");
order.setsSalesOrderPayTypeID(payTypeId); order.setsDeliveryTypeID("1");
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : ""))); order.setsSalesOrderPayTypeID(payTypeId);
order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal); order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal); order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal);
order.setsFormID(formId); order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal);
order.setsB2BOrderTypeID("2"); order.setsFormID(formId);
order.setsB2BOrderType("门店装饰订单"); order.setsB2BOrderTypeID("2");
order.setsOrderMemo(memo); order.setsB2BOrderType("门店装饰订单");
jdbcTemplate.save(order); order.setsOrderMemo(memo);
jdbcTemplate.save(order);
TSalesOrderDtl dtl = new TSalesOrderDtl();
String sSalesOrderID = order.getsSalesOrderID(); TSalesOrderDtl dtl = new TSalesOrderDtl();
Date dUpdate = new Date(); String sSalesOrderID = order.getsSalesOrderID();
dtl.setsSalesOrderID(sSalesOrderID); Date dUpdate = new Date();
dtl.setdUpdate(dUpdate); dtl.setsSalesOrderID(sSalesOrderID);
dtl.setnAgentID(nAgentID); dtl.setdUpdate(dUpdate);
dtl.setnDisAmount(BigDecimal.ZERO); dtl.setnAgentID(nAgentID);
dtl.setnExpressFee(BigDecimal.ZERO); dtl.setnDisAmount(BigDecimal.ZERO);
dtl.setnGoodsID(nGoodsID); dtl.setnExpressFee(BigDecimal.ZERO);
dtl.setnIdx(1); dtl.setnGoodsID(nGoodsID);
dtl.setnSaleAmount(nTotalSaleAmount); dtl.setnIdx(1);
dtl.setnSalePrice(nRealSalePrice); dtl.setnSaleAmount(nTotalSaleAmount);
dtl.setnSaleQty(Qty); dtl.setnSalePrice(nRealSalePrice);
dtl.setnTag(0); dtl.setnSaleQty(Qty);
dtl.setsAgentContractNO(sAgentContractNO); dtl.setnTag(0);
dtl.setdLastUpdateTime(new Date()); dtl.setsAgentContractNO(sAgentContractNO);
dtl.setsBarcode(sBarcode); dtl.setdLastUpdateTime(new Date());
dtl.setsGoodsDesc(sGoodsDesc); dtl.setsBarcode(sBarcode);
dtl.setsMemo(memo); dtl.setsGoodsDesc(sGoodsDesc);
dtl.setsSalesOrderID(sSalesOrderID); dtl.setsMemo(memo);
dtl.setsWarehouseNO(sWarehouseNO); dtl.setsSalesOrderID(sSalesOrderID);
jdbcTemplate.save(dtl); dtl.setsWarehouseNO(sWarehouseNO);
this.sendWxMessage(order.getsSalesOrderID()); jdbcTemplate.save(dtl);
return order.getsSalesOrderID(); this.sendWxMessage(order.getsSalesOrderID());
} return order.getsSalesOrderID();
}
private void saveOrderBankAccount(String sCustNO, String sBankType, String sBankAccountNO) {
if(StringUtil.isNotBlank(sCustNO, sBankType, sBankAccountNO)) { private void saveOrderBankAccount(String sCustNO, String sBankType, String sBankAccountNO) {
String sql = "" if(StringUtil.isNotBlank(sCustNO, sBankType, sBankAccountNO)) {
+ "DECLARE @CustNO VARCHAR(36) " String sql = ""
+ "DECLARE @CustName VARCHAR(36) " + "DECLARE @CustNO VARCHAR(36) "
+ "DECLARE @BankType VARCHAR(36) " + "DECLARE @CustName VARCHAR(36) "
+ "DECLARE @BankTypeID VARCHAR(36) " + "DECLARE @BankType VARCHAR(36) "
+ "DECLARE @BankAccountNO VARCHAR(36) " + "DECLARE @BankTypeID VARCHAR(36) "
+ "SELECT @CustNO = '" + sCustNO + "' " + "DECLARE @BankAccountNO VARCHAR(36) "
+ "SELECT @BankType = '" + sBankType + "' " + "SELECT @CustNO = '" + sCustNO + "' "
+ "SELECT @BankAccountNO = '" + sBankAccountNO + "' " + "SELECT @BankType = '" + sBankType + "' "
+ "SELECT @CustName = sCustName FROM tCustomer WHERE sCustNO = @CustNO " + "SELECT @BankAccountNO = '" + sBankAccountNO + "' "
+ "SELECT @BankTypeID = sComID from tCommon where sLangID = '936' and sCommonNO = 'Bank' and sComDesc = @BankType " + "SELECT @CustName = sCustName FROM tCustomer WHERE sCustNO = @CustNO "
+ "SELECT @BankTypeID = ISNULL(@BankTypeID, @BankType) " + "SELECT @BankTypeID = sComID from tCommon where sLangID = '936' and sCommonNO = 'Bank' and sComDesc = @BankType "
+ "SELECT @CustName = ISNULL(@CustName, @CustNO) " + "SELECT @BankTypeID = ISNULL(@BankTypeID, @BankType) "
+ "IF NOT EXISTS (SELECT * FROM tCustBank WHERE sCustNO = @CustNO AND sBankAccountNO = @BankAccountNO) " + "SELECT @CustName = ISNULL(@CustName, @CustNO) "
+ "BEGIN " + "IF NOT EXISTS (SELECT * FROM tCustBank WHERE sCustNO = @CustNO AND sBankAccountNO = @BankAccountNO) "
+ "INSERT INTO tCustBank " + "BEGIN "
+ "(sCustNO, sBankTypeID, sBankType, sBankAccountNO, sBankAccount, nTag, sCreateUser, dCreateDate, sConfirmUser, dConfirmDate, dLastUpdateTime) " + "INSERT INTO tCustBank "
+ "VALUES " + "(sCustNO, sBankTypeID, sBankType, sBankAccountNO, sBankAccount, nTag, sCreateUser, dCreateDate, sConfirmUser, dConfirmDate, dLastUpdateTime) "
+ "(@CustNO, @BankTypeID, @BankType, @BankAccountNO, @CustNO, 0, @CustNO, GETDATE(), @CustNO, GETDATE(), GETDATE())" + "VALUES "
+ "END"; + "(@CustNO, @BankTypeID, @BankType, @BankAccountNO, @CustNO, 0, @CustNO, GETDATE(), @CustNO, GETDATE(), GETDATE())"
jdbcTemplate.update(sql); + "END";
} jdbcTemplate.update(sql);
} }
}
@Override
public void confirmReceipt(String custNo, String subOrderID) { @Override
String sql = "" public void confirmReceipt(String custNo, String subOrderID) {
+ "DECLARE @CustNO VARCHAR(20) " String sql = ""
+ "DECLARE @SubOrderID VARCHAR(20) " + "DECLARE @CustNO VARCHAR(20) "
+ "DECLARE @SalesOrderID VARCHAR(20) " + "DECLARE @SubOrderID VARCHAR(20) "
+ "DECLARE @OrderStatusName VARCHAR(20) " + "DECLARE @SalesOrderID VARCHAR(20) "
+ "DECLARE @OrderStatus INT " + "DECLARE @OrderStatusName VARCHAR(20) "
+ "DECLARE @TargetStatus INT " + "DECLARE @OrderStatus INT "
+ "SELECT @CustNO = '" + custNo + "' " + "DECLARE @TargetStatus INT "
+ "SELECT @SubOrderID = '" + subOrderID + "' " + "SELECT @CustNO = '" + custNo + "' "
+ "SELECT @TargetStatus = 16 " + "SELECT @SubOrderID = '" + subOrderID + "' "
+ "SELECT @OrderStatusName = '收货完成' " + "SELECT @TargetStatus = 16 "
+ "SELECT @OrderStatus = nOrderStatus FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID " + "SELECT @OrderStatusName = '收货完成' "
+ "IF @OrderStatus&@TargetStatus = 0 " + "SELECT @OrderStatus = nOrderStatus FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID "
+ "BEGIN " + "IF @OrderStatus&@TargetStatus = 0 "
+ "SELECT @SalesOrderID = sSalesOrderID FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID " + "BEGIN "
+ "UPDATE tSalesOrderSub SET nOrderStatus = nOrderStatus|@TargetStatus, nOrderStatusName = @OrderStatusName, dLastUpdateTime = GETDATE() WHERE sSubOrderID = @SubOrderID " + "SELECT @SalesOrderID = sSalesOrderID FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID "
+ "UPDATE tSalesOrderSubDtl SET nReceiveQty = td.nSendQty, nReceiveAmount = td.nSendAmount, dLastUpdateTime = GETDATE() FROM tSalesOrderSub t, tSalesOrderSubDtl td WHERE t.sSubOrderID = td.sSubOrderID AND t.sSubOrderID = @SubOrderID AND td.nReceiveQty IS NULL " + "UPDATE tSalesOrderSub SET nOrderStatus = nOrderStatus|@TargetStatus, nOrderStatusName = @OrderStatusName, dLastUpdateTime = GETDATE() WHERE sSubOrderID = @SubOrderID "
+ "DECLARE @Idx INT " + "UPDATE tSalesOrderSubDtl SET nReceiveQty = td.nSendQty, nReceiveAmount = td.nSendAmount, dLastUpdateTime = GETDATE() FROM tSalesOrderSub t, tSalesOrderSubDtl td WHERE t.sSubOrderID = td.sSubOrderID AND t.sSubOrderID = @SubOrderID AND td.nReceiveQty IS NULL "
+ "SELECT @Idx = ISNULL(MAX(nIdx), 0) + 1 FROM tSalesOrderSubStatus WHERE sSubOrderID = @SubOrderID " + "DECLARE @Idx INT "
+ "INSERT INTO tSalesOrderSubStatus " + "SELECT @Idx = ISNULL(MAX(nIdx), 0) + 1 FROM tSalesOrderSubStatus WHERE sSubOrderID = @SubOrderID "
+ "(sSubOrderID, nIdx, sSalesOrderID, nOrderStatusStep, sOrderStatusName, sOrderStatusUser, dOrderStatusTime, dLastUpdateTime) " + "INSERT INTO tSalesOrderSubStatus "
+ "VALUES " + "(sSubOrderID, nIdx, sSalesOrderID, nOrderStatusStep, sOrderStatusName, sOrderStatusUser, dOrderStatusTime, dLastUpdateTime) "
+ "(@SubOrderID, @Idx, @SalesOrderID, @TargetStatus, @OrderStatusName, @CustNO, GETDATE(), GETDATE()) " + "VALUES "
+ "exec up_UpdateSalesOrderStatus @SalesOrderID, @SubOrderID, @CustNO, @TargetStatus, @OrderStatusName, @OrderStatusName " + "(@SubOrderID, @Idx, @SalesOrderID, @TargetStatus, @OrderStatusName, @CustNO, GETDATE(), GETDATE()) "
+ "END" + "exec up_UpdateSalesOrderStatus @SalesOrderID, @SubOrderID, @CustNO, @TargetStatus, @OrderStatusName, @OrderStatusName "
; + "END"
jdbcTemplate.update(sql); ;
} jdbcTemplate.update(sql);
}
@Override
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID) { @Override
return jdbcTemplate.queryForList("select * from tSalesOrderDeliverSubDtl where nTag&1 = 0 and sAocOrderID = ?", aocOrderID); public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID) {
} return jdbcTemplate.queryForList("select * from tSalesOrderDeliverSubDtl where nTag&1 = 0 and sAocOrderID = ?", aocOrderID);
}
private void sendWxMessage(String sSalesOrderID) {
TSalesOrder order = jdbcTemplate.queryForBean("select * from tSalesOrder where sSalesOrderID = ?", TSalesOrder.class, sSalesOrderID); private void sendWxMessage(String sSalesOrderID) {
String salesmanNo = order.getsSalesmanNO(); TSalesOrder order = jdbcTemplate.queryForBean("select * from tSalesOrder where sSalesOrderID = ?", TSalesOrder.class, sSalesOrderID);
String shopNo = order.getsShopNO(); String salesmanNo = order.getsSalesmanNO();
BigDecimal totalAmount = order.getnTotalSaleAmount(); String shopNo = order.getsShopNO();
BigDecimal totalSaleQty = order.getnTotalSaleQty(); BigDecimal totalAmount = order.getnTotalSaleAmount();
String payType = order.getsSalesOrderPayType(); BigDecimal totalSaleQty = order.getnTotalSaleQty();
Map<String, Object> salesman = null; String payType = order.getsSalesOrderPayType();
try { Map<String, Object> salesman = null;
salesman = jdbcTemplate.queryForMap("select * from tSalesman where sSalesmanNO = ?", salesmanNo); try {
} catch (EmptyResultDataAccessException e) { salesman = jdbcTemplate.queryForMap("select * from tSalesman where sSalesmanNO = ?", salesmanNo);
e.printStackTrace(); } catch (EmptyResultDataAccessException e) {
} e.printStackTrace();
if(salesman != null) { }
Map<String, Object> shop = jdbcTemplate.queryForMap("select * from tShop where sShopNO = ?", shopNo); if(salesman != null) {
String custNo = (String)shop.get("sCustNO"); String dateString = DateUtil.format(new Date());
String shopMemo = (String)shop.get("sMemo"); Map<String, Object> shop = jdbcTemplate.queryForMap("select * from tShop where sShopNO = ?", shopNo);
Map<String, Object> cust = jdbcTemplate.queryForMap("select * from tCustomer where sCustNO = ?", custNo);; String custNo = (String)shop.get("sCustNO");
String custName = (String)cust.get("sCustName"); String shopMemo = (String)shop.get("sMemo");
String sCompanyAccountID = (String)salesman.get("sCompanyAccountID"); Map<String, Object> cust = jdbcTemplate.queryForMap("select * from tCustomer where sCustNO = ?", custNo);;
WxMessage wxMessage = new WxMessage(sCompanyAccountID); String custName = (String)cust.get("sCustName");
MiniprogramNotice notice = new MiniprogramNotice(); String sCompanyAccountID = (String)salesman.get("sCompanyAccountID");
wxMessage.setMiniprogram_notice(notice); WxMessage wxMessage = new WxMessage(sCompanyAccountID);
notice.setDescription("当前时间"); MiniprogramNotice notice = new MiniprogramNotice();
notice.setTitle("认证审核通知"); wxMessage.setMiniprogram_notice(notice);
notice.setPage("pages/ordermanage/detail/detail?SalesmanNO=" + salesmanNo + "&isShare=1&id=" + sSalesOrderID + "&isActive=0"); notice.setDescription(dateString);
Map<Object, Object> params = new LinkedHashMap<Object, Object>(); notice.setTitle("客户订单通知");
params.put("订单状态", "待审核"); notice.setPage("pages/ordermanage/detail/detail?SalesmanNO=" + salesmanNo + "&isShare=1&id=" + sSalesOrderID + "&isActive=0");
params.put("客户", custName); Map<Object, Object> params = new LinkedHashMap<Object, Object>();
params.put("订单金额", totalAmount); params.put("订单状态", "待审核");
params.put("商品数量", totalSaleQty); params.put("客户", custName);
params.put("支付方式", payType); params.put("订单金额", totalAmount);
params.put("订单时间", DateUtil.format(new Date())); params.put("商品数量", totalSaleQty);
params.put("备注", StringUtil.isBlank(shopMemo) ? " " : shopMemo); params.put("支付方式", payType);
notice.setContent_item(params); params.put("订单时间", dateString);
wxService.sendMessage(wxMessage); params.put("备注", StringUtil.isBlank(shopMemo) ? " " : shopMemo);
} notice.setContent_item(params);
} wxService.sendMessage(wxMessage);
}
} }
}
package com.egolm.shop.api.service.impl; package com.egolm.shop.api.service.impl;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.QiyeWxService; import com.egolm.shop.api.service.QiyeWxService;
import com.egolm.shop.common.utils.HttpUtil; import com.egolm.shop.api.service.QiyeWxService.WxMessage;
import com.egolm.shop.common.utils.HttpUtil.HttpReqObject; import com.egolm.shop.common.utils.HttpUtil;
import com.egolm.shop.common.utils.HttpUtil.HttpRespObject; import com.egolm.shop.common.utils.HttpUtil.HttpReqObject;
import com.egolm.shop.common.utils.HttpUtil.JsonReqObject; import com.egolm.shop.common.utils.HttpUtil.HttpRespObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion; import com.egolm.shop.common.utils.HttpUtil.JsonReqObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion;
@Service
public class QiyeWxServiceImpl implements QiyeWxService { @Service
public class QiyeWxServiceImpl implements QiyeWxService {
@Value("${qiyewx.corpid}")
private String corpid; @Value("${qiyewx.corpid}")
private String corpid;
@Value("${qiyewx.corpsecret}")
private String corpsecret; @Value("${qiyewx.corpsecret}")
private String corpsecret;
@Value("${qiyewx.baseUrl}")
private String baseUrl; @Value("${qiyewx.baseUrl}")
private String baseUrl;
@Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid; @Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid;
@Autowired
private RedisTemplate<String, String> redis; @Autowired
private RedisTemplate<String, String> redis;
@Override
public String getTokenString() { @Override
String redisCacheKey = PrefixRedisTokenKey + corpid; public String getTokenString() {
Long systemTime = System.currentTimeMillis(); String redisCacheKey = PrefixRedisTokenKey + corpid;
String tokenObjectString = redis.opsForValue().get(redisCacheKey); Long systemTime = System.currentTimeMillis();
if(StringUtil.isNotBlank(tokenObjectString)) { String tokenObjectString = redis.opsForValue().get(redisCacheKey);
JSONObject tokenObject = JSON.parseObject(tokenObjectString); if(StringUtil.isNotBlank(tokenObjectString)) {
Integer errcode = tokenObject.getInteger("errcode"); JSONObject tokenObject = JSON.parseObject(tokenObjectString);
if(errcode == 0) { Integer errcode = tokenObject.getInteger("errcode");
Long expires_in = tokenObject.getLong("expires_in"); if(errcode == 0) {
String loadTimeString = tokenObject.getString("loadTime"); Long expires_in = tokenObject.getLong("expires_in");
if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) { String loadTimeString = tokenObject.getString("loadTime");
Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss"); if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) {
Long expireTime = loadTime.getTime() + (expires_in*1000L); Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss");
if((expireTime - DevTime) > systemTime) { Long expireTime = loadTime.getTime() + (expires_in*1000L);
String access_token = tokenObject.getString("access_token"); if((expireTime - DevTime) > systemTime) {
if(StringUtil.isNotBlank(access_token)) { String access_token = tokenObject.getString("access_token");
return access_token; if(StringUtil.isNotBlank(access_token)) {
} return access_token;
} }
} }
} }
} }
String requestUrl = baseUrl + MessageFormat.format(UrlGetToken, corpid, corpsecret); }
HttpRespObject resp = HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).get(new HttpReqObject(requestUrl, null, null)); String requestUrl = baseUrl + MessageFormat.format(UrlGetToken, corpid, corpsecret);
if(resp.getHttpCode() == 200) { HttpRespObject resp = HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).get(new HttpReqObject(requestUrl, null, null));
String text = resp.getResponseBody(); if(resp.getHttpCode() == 200) {
JSONObject tokenObject = JSON.parseObject(text); String text = resp.getResponseBody();
Integer code = tokenObject.getInteger("errcode"); JSONObject tokenObject = JSON.parseObject(text);
if(code == 0) { Integer code = tokenObject.getInteger("errcode");
tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); if(code == 0) {
redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString()); tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
return tokenObject.getString("access_token"); redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString());
} return tokenObject.getString("access_token");
} }
return null; }
} return null;
}
@Override
public void refreshToken() { @Override
String redisCacheKey = PrefixRedisTokenKey + corpid; public void refreshToken() {
redis.delete(redisCacheKey); String redisCacheKey = PrefixRedisTokenKey + corpid;
} redis.delete(redisCacheKey);
}
@Override
public void sendMessage(WxMessage wxMessage) { @Override
String tokenString = this.getTokenString(); public void sendMessage(WxMessage wxMessage) {
String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString); String tokenString = this.getTokenString();
Map<String, String> headers = new HashMap<String, String>(); String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString);
headers.put("content-type", "application/x-www-form-urlencoded"); Map<String, String> headers = new HashMap<String, String>();
wxMessage.getMiniprogram_notice().setAppid(redirectAppid); headers.put("content-type", "application/x-www-form-urlencoded");
HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).postJson(new JsonReqObject(requestUrl, wxMessage, headers)); wxMessage.getMiniprogram_notice().setAppid(redirectAppid);
} HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).postJson(new JsonReqObject(requestUrl, wxMessage, headers));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment