Commit fe513080608aac4f8020244d85308ffd4b5e6e37

Authored by shiyang
1 parent d73e502002
Exists in master and in 1 other branch dev

群组聊天商品下单支付模块

Showing 19 changed files with 1068 additions and 1 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/GroupOrderController.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.controller;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5 +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  6 +import com.lyms.talkonlineweb.annotation.Resubmit;
  7 +import com.lyms.talkonlineweb.annotation.TokenRequired;
  8 +import com.lyms.talkonlineweb.domain.*;
  9 +import com.lyms.talkonlineweb.enums.PayStatus;
  10 +import com.lyms.talkonlineweb.result.BaseResponse;
  11 +import com.lyms.talkonlineweb.service.*;
  12 +import com.lyms.talkonlineweb.util.*;
  13 +import lombok.extern.log4j.Log4j2;
  14 +import org.apache.commons.io.IOUtils;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.beans.factory.annotation.Value;
  17 +import org.springframework.transaction.annotation.Transactional;
  18 +import org.springframework.web.bind.annotation.PostMapping;
  19 +import org.springframework.web.bind.annotation.RequestBody;
  20 +import org.springframework.web.bind.annotation.RequestMapping;
  21 +import org.springframework.web.bind.annotation.RestController;
  22 +
  23 +import javax.servlet.http.HttpServletRequest;
  24 +import javax.servlet.http.HttpServletResponse;
  25 +import java.io.IOException;
  26 +import java.io.PrintWriter;
  27 +import java.util.*;
  28 +
  29 +/**
  30 + * @ProjectName: talkonline
  31 + * @Package: com.lyms.talkonlineweb.controller
  32 + * @ClassName: GroupOrderController
  33 + * @Author: sy
  34 + * @Description: 支付订单类
  35 + * @Date: 2022-04-22 09:57
  36 + * @Version:
  37 + */
  38 +@RestController
  39 +@RequestMapping("GroupOrder")
  40 +@Log4j2
  41 +public class GroupOrderController {
  42 +
  43 + /**
  44 + * 商品信息
  45 + */
  46 + @Autowired
  47 + private LymsGroupGoodsService lymsGroupGoodsService;
  48 +
  49 + /**
  50 + * 患者
  51 + */
  52 + @Autowired
  53 + private LymsPatientService lymsPatientService;
  54 +
  55 + /**
  56 + * 订单信息
  57 + */
  58 + @Autowired
  59 + private LymsGroupOrderService lymsGroupOrderService;
  60 +
  61 + /**
  62 + * 订单量
  63 + */
  64 + @Autowired
  65 + private LymsOrderDataService lymsOrderDataService;
  66 +
  67 + /**
  68 + * 微信回调通知接口
  69 + */
  70 + @Value("${notify.url}")
  71 + private String notifyUrl;
  72 + /**
  73 + * 终端ip
  74 + */
  75 + @Value("${weixin.createIP}")
  76 + private String createIP;
  77 +
  78 +
  79 + /**
  80 + * 创建支付订单,并把订单提交到微信平台
  81 + * 传入患者id和购买数量
  82 + * https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_1 微信统一下单api文档地址
  83 + * @param lymsOrder
  84 + * @param request
  85 + * @param response
  86 + */
  87 + @PostMapping("createPayOrder")
  88 + @TokenRequired
  89 + @Resubmit
  90 + @Transactional(rollbackFor = Exception.class)
  91 + public BaseResponse createPayOrder(@RequestBody LymsGroupOrder lymsOrder,
  92 + HttpServletRequest request, HttpServletResponse response) {
  93 +
  94 + log.info("create pay order request info : {}",lymsOrder.toString());
  95 +
  96 + BaseResponse baseResponse = new BaseResponse();
  97 + //参数校验
  98 + if (lymsOrder.getPid() == null || CollectionUtils.isEmpty(lymsOrder.getOrderData()))
  99 + {
  100 + baseResponse.setErrorcode(1);
  101 + baseResponse.setErrormsg("创建订单参数错误");
  102 + return baseResponse;
  103 + }
  104 + for (LymsOrderData orderData : lymsOrder.getOrderData()) {
  105 + if (null==orderData.getGid() || null==orderData.getOrderNum()) {
  106 + baseResponse.setErrorcode(1);
  107 + baseResponse.setErrormsg("创建订单参数错误");
  108 + return baseResponse;
  109 + }
  110 + }
  111 + LymsPatient patient = lymsPatientService.getById(lymsOrder.getPid());
  112 + if (patient == null)
  113 + {
  114 + baseResponse.setErrorcode(1);
  115 + baseResponse.setErrormsg("用户不存在");
  116 + return baseResponse;
  117 + }
  118 + if (StringUtil.isEmpty(patient.getOpenid()))
  119 + {
  120 + baseResponse.setErrorcode(1);
  121 + baseResponse.setErrormsg("用户Openid不存在");
  122 + return baseResponse;
  123 + }
  124 +
  125 + try
  126 + {
  127 + //生成系统订单号
  128 + String orderNo = StringUtil.getUniqueNo();
  129 + String wieXinOrderNo = StringUtil.getUniqueWeixNo();
  130 + lymsOrder.setPaytime(new Date());
  131 + lymsOrder.setOrderno(orderNo);
  132 + lymsOrder.setPayorderid(wieXinOrderNo);
  133 + lymsOrder.setStatus(PayStatus.CREATED.getCode());
  134 + lymsOrder.setOpenid(patient.getOpenid());
  135 + lymsGroupOrderService.save(lymsOrder);
  136 + //处理订单量&更新订单
  137 + Integer total= 0;
  138 + for (LymsOrderData orderData : lymsOrder.getOrderData()) {
  139 + LambdaQueryWrapper<LymsGroupGoods> wrapper = new QueryWrapper().lambda();
  140 + wrapper.eq(LymsGroupGoods::getId, orderData.getGid());
  141 + LymsGroupGoods goods = lymsGroupGoodsService.getOne(wrapper);
  142 + if (goods == null || goods.getPrice() <= 0 )
  143 + {
  144 + baseResponse.setErrorcode(1);
  145 + baseResponse.setErrormsg("商品价格配置不存在");
  146 + return baseResponse;
  147 + }
  148 + if(null ==lymsOrder.getId()){
  149 + baseResponse.setErrorcode(1);
  150 + baseResponse.setErrormsg("订单信息id获取异常!");
  151 + return baseResponse;
  152 + }
  153 + orderData.setOrderId(lymsOrder.getId());
  154 + orderData.setGid(goods.getId());
  155 + orderData.setStartTime(new Date());
  156 + orderData.setEndTime(DateUtil.addDay(new Date(), orderData.getOrderNum()*goods.getTimeLimit()));
  157 + total+=orderData.getOrderNum() * goods.getPrice();
  158 + lymsOrderDataService.save(orderData);
  159 + }
  160 + lymsOrder.setTotalPrices(total);
  161 + //创建微信订单
  162 + Map<String, String> data = createWxOrder(lymsOrder);
  163 + if (data != null) {
  164 + //更新订单总金额
  165 + lymsGroupOrderService.updateById(lymsOrder);
  166 + data.put("orderNo", orderNo);
  167 + baseResponse.setObject(data);
  168 + return baseResponse;
  169 + }
  170 +
  171 + }catch (Exception e){
  172 + log.error("create order error.",e);
  173 + }
  174 + baseResponse.setErrorcode(1);
  175 + baseResponse.setErrormsg("创建订单失败");
  176 + return baseResponse;
  177 + }
  178 +
  179 + /**
  180 + * 创建微信订单
  181 + */
  182 + private Map<String,String> createWxOrder(LymsGroupOrder lymsOrder) throws Exception
  183 + {
  184 + try {
  185 + String xml = buildRequestXml(lymsOrder);
  186 + log.info("create order pid : {},buildRequestMap xml : {}",lymsOrder.getPid(),xml);
  187 +
  188 + //调用微信统一下单接口
  189 + String result = HttpUtil.postData(Constant.PAY_URL, xml);
  190 + log.info("wx create order result : {}" ,result);
  191 +
  192 + return parseWxResult(result);
  193 + } catch (Exception e) {
  194 + log.error("createWxOrder error.",e);
  195 + throw e;
  196 + }
  197 + }
  198 +
  199 +
  200 + /**
  201 + * 解析微信创建订单的结果
  202 + * @param resultXml
  203 + * @throws Exception
  204 + */
  205 + private Map<String,String> parseWxResult(String resultXml) throws Exception{
  206 + try
  207 + {
  208 + Map<String,String> data = new HashMap(5);
  209 + Map<String,String> retMap = XmlUtil.xmlToMap(resultXml);
  210 + System.out.println("retMap:"+retMap);
  211 + String success = "SUCCESS";
  212 + if (retMap != null && retMap.size() > 0 && success.equals(retMap.get("return_code")) && success.equals(retMap.get("result_code")))
  213 + {
  214 + SortedMap<Object,Object> map=new TreeMap<>();
  215 + //重新拼接支付sign
  216 + String nonceStr=NumberUtil.getRandomString(16);
  217 + String timeStamp=System.currentTimeMillis()/1000+"";
  218 + map.put("appId",Constant.PAT_APP_ID);
  219 + map.put("nonceStr",nonceStr);
  220 + map.put("package","prepay_id="+retMap.get("prepay_id"));
  221 + map.put("signType","MD5");
  222 + map.put("timeStamp",timeStamp);
  223 + //System.out.println("createSign:"+createSign(null, map));
  224 + //返给前端加密后的sign,
  225 + data.put("packageValue",retMap.get("prepay_id"));
  226 + data.put("nonceStr",nonceStr);
  227 + data.put("paySign",createSign(null, map));
  228 + data.put("timeStamp",timeStamp);
  229 + return data;
  230 + }
  231 + }
  232 + catch (Exception e)
  233 + {
  234 + log.error("parse wx result error.",e);
  235 + throw e;
  236 + }
  237 + return null;
  238 + }
  239 +
  240 +
  241 + /**
  242 + * 构建微信订单参数
  243 + * @param lymsOrder
  244 + * @return
  245 + * @throws Exception
  246 + */
  247 + public String buildRequestXml(LymsGroupOrder lymsOrder) throws Exception {
  248 + Map<String,String> paramMap = new TreeMap((key1,key2) -> {
  249 + return key1.toString().compareTo(key2.toString());
  250 + }
  251 + );
  252 + //小程序ID
  253 + paramMap.put("appid", Constant.PAT_APP_ID);
  254 + //商户号
  255 + paramMap.put("mch_id", Constant.MCHID);
  256 + //随机字符串
  257 + paramMap.put("nonce_str", NumberUtil.getRandomString(16));
  258 + //签名类型
  259 + paramMap.put("sign_type", "MD5");
  260 + //商户订单号
  261 + paramMap.put("out_trade_no", lymsOrder.getPayorderid());
  262 + //标价金额
  263 + paramMap.put("total_fee", String.valueOf(lymsOrder.getTotalPrices()));
  264 + //终端IP
  265 + paramMap.put("spbill_create_ip", createIP);
  266 + //通知地址
  267 + paramMap.put("notify_url", notifyUrl);
  268 + //交易类型
  269 + paramMap.put("trade_type", "JSAPI");
  270 + //用户标识
  271 + paramMap.put("openid", lymsOrder.getOpenid());
  272 + //商品描述
  273 + paramMap.put("body", "问诊支付");
  274 +
  275 + String reqSign = PayDigestUtil.getSign(paramMap, Constant.REQ_KEY);
  276 + // 签名
  277 + paramMap.put("sign", reqSign);
  278 + return XmlUtil.mapToXml(paramMap);
  279 + }
  280 +
  281 +
  282 + /**
  283 + * 微信支付成功后回调接口
  284 + * https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_7&index=8
  285 + * @param request
  286 + * @param response
  287 + * @return
  288 + */
  289 + @PostMapping("payNotify")
  290 + public void payNotify(HttpServletRequest request, HttpServletResponse response) {
  291 +
  292 + Map<String,String> result = new HashMap<>(2);
  293 + result.put("return_code","<![CDATA[FAIL]]>");
  294 + result.put("return_msg","参数错误");
  295 + try {
  296 + Map<String, String> paramMap = getPayNotifyParamMap(request);
  297 +
  298 + //验证支付通知的参数合法性
  299 + if (!verifyPayNotify(paramMap)) {
  300 + //微信支付订单号
  301 + String payOrderId = paramMap.get("transaction_id");
  302 + //商户订单号
  303 + String mchOrderNo = paramMap.get("out_trade_no");
  304 + LambdaQueryWrapper<LymsGroupOrder> wrapper = new QueryWrapper().lambda();
  305 + wrapper.eq(LymsGroupOrder::getOrderno, mchOrderNo);
  306 + LymsGroupOrder order=new LymsGroupOrder();
  307 + order.setPayorderid(payOrderId);
  308 + boolean f=lymsGroupOrderService.update(order, wrapper);
  309 +
  310 + }
  311 + outResult(response, XmlUtil.mapToXml(result));
  312 + }catch (Exception e){
  313 + log.error("pay notify error.",e);
  314 + try
  315 + {
  316 + outResult(response, XmlUtil.mapToXml(result));
  317 + }catch (Exception e1) {
  318 +
  319 + }
  320 + }
  321 + }
  322 +
  323 +
  324 + /**
  325 + * 回调接口响应微信
  326 + * @param response
  327 + * @param content
  328 + */
  329 + private void outResult(HttpServletResponse response, String content) {
  330 + response.setContentType("text/html");
  331 + PrintWriter pw;
  332 + try {
  333 + pw = response.getWriter();
  334 + pw.print(content);
  335 + log.info("response pay complete.");
  336 + } catch (IOException e) {
  337 + log.error("response pay write exception.", e);
  338 + }
  339 + }
  340 +
  341 +
  342 + /**
  343 + * 解析支付通知参数为map
  344 + * @param request
  345 + * @return
  346 + * @throws Exception
  347 + */
  348 + public Map<String, String> getPayNotifyParamMap(HttpServletRequest request) throws Exception{
  349 + try
  350 + {
  351 + String resultXml = IOUtils.toString(request.getInputStream(),"utf-8");
  352 + log.info("pay notify info : {}",resultXml);
  353 + if (StringUtil.isNotEmpty(resultXml))
  354 + {
  355 + Map<String, String> retMap = XmlUtil.xmlToMap(resultXml);
  356 + String success = "SUCCESS";
  357 + if (retMap != null && retMap.size() > 0 && success.equals(retMap.get("return_code")) && success.equals(retMap.get("result_code")))
  358 + {
  359 + return retMap;
  360 + }
  361 + }
  362 + }catch (Exception e)
  363 + {
  364 + log.error("get pay notify error.",e);
  365 + throw e;
  366 + }
  367 + return null;
  368 + }
  369 +
  370 + /**
  371 + * 微信回调参数验证
  372 + * @param map
  373 + * @return
  374 + */
  375 + public boolean verifyPayNotify(Map<String, String> map) {
  376 + //商户id
  377 + String mchId = map.get("mch_id");
  378 + //微信支付订单号
  379 + String payOrderId = map.get("transaction_id");
  380 + //商户订单号
  381 + String mchOrderNo = map.get("out_trade_no");
  382 + //现金支付金额
  383 + String amount = map.get("cash_fee");
  384 + //签名
  385 + String sign = map.get("sign");
  386 +
  387 + if (StringUtil.isEmpty(mchId)) {
  388 + log.warn("Params error. mchId : {}", mchId);
  389 + return false;
  390 + }
  391 + if (StringUtil.isEmpty(payOrderId)) {
  392 + log.warn("Params error. payOrderId : {}", payOrderId);
  393 + return false;
  394 + }
  395 + if (StringUtil.isEmpty(amount)) {
  396 + log.warn("Params error. amount : {}", amount);
  397 + return false;
  398 + }
  399 + if (StringUtil.isEmpty(sign)) {
  400 + log.warn("Params error. sign : {}", sign);
  401 + return false;
  402 + }
  403 +
  404 + // 验证签名
  405 + if (!verifySign(map)) {
  406 + log.warn("verify params sign failed. payOrderId={}", payOrderId);
  407 + return false;
  408 + }
  409 +
  410 + // 根据payOrderId查询业务订单,验证订单是否存在
  411 + LambdaQueryWrapper<LymsGroupOrder> wrapper = new QueryWrapper().lambda();
  412 + wrapper.eq(LymsGroupOrder::getOrderno, mchOrderNo);
  413 + List<LymsGroupOrder> lymsOrders = lymsGroupOrderService.list(wrapper);
  414 + if (CollectionUtils.isNotEmpty(lymsOrders)) {
  415 + log.warn("local orderno not exists,payOrderId : {},orderno : {}", payOrderId, mchOrderNo);
  416 + return false;
  417 + }
  418 + // 核对金额
  419 + if (lymsOrders.get(0).getTotalPrices() != Integer.parseInt(amount)) {
  420 + log.warn("Inconsistent payment amount ,dbPayPrice : {},payPrice : {}", lymsOrders.get(0).getTotalPrices(), amount);
  421 + return false;
  422 + }
  423 + return true;
  424 + }
  425 +
  426 +
  427 + /**
  428 + * 回调参数的签名验证
  429 + * @param map
  430 + * @return
  431 + */
  432 + public boolean verifySign(Map<String, String> map) {
  433 + String mchId = map.get("mch_id");
  434 + //检查商户id
  435 + if (!Constant.MCHID.equals(mchId) ) {
  436 + return false;
  437 + }
  438 + String localSign = PayDigestUtil.getSign(map, Constant.REQ_KEY, "sign");
  439 + String sign = map.get("sign");
  440 + return localSign.equalsIgnoreCase(sign);
  441 + }
  442 +
  443 +
  444 + /**
  445 + * 微信支付签名算法sign
  446 + * @param characterEncoding
  447 + * @param parameters
  448 + * @return
  449 + */
  450 + public static String createSign(String characterEncoding,SortedMap<Object,Object> parameters){
  451 + StringBuffer sb = new StringBuffer();
  452 + Set es = parameters.entrySet();//所有参与传参的参数按照accsii排序(升序)
  453 + Iterator it = es.iterator();
  454 + while(it.hasNext()) {
  455 + Map.Entry entry = (Map.Entry)it.next();
  456 + String k = (String)entry.getKey();
  457 + Object v = entry.getValue();
  458 + if(null != v && !"".equals(v)
  459 + && !"sign".equals(k) && !"key".equals(k)) {
  460 + sb.append(k + "=" + v + "&");
  461 + }
  462 + }
  463 +
  464 + sb.append("key=" + Constant.REQ_KEY);
  465 + System.out.println("签名字符串:"+sb.toString());
  466 + System.out.println("签名MD5未变大写:" + MD5Util.MD5Encode(sb.toString(), characterEncoding));
  467 + String sign = MD5Util.MD5Encode(sb.toString(), characterEncoding).toUpperCase();
  468 + return sign;
  469 + }
  470 +
  471 +
  472 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsGroupGoods.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import java.io.Serializable;
  8 +import java.util.Date;
  9 +import lombok.Data;
  10 +
  11 +/**
  12 + * 群组聊天商品
  13 + * @TableName lyms_group_goods
  14 + */
  15 +@TableName(value ="lyms_group_goods")
  16 +@Data
  17 +public class LymsGroupGoods implements Serializable {
  18 + /**
  19 + * 主键id,自增
  20 + */
  21 + @TableId(value = "id", type = IdType.AUTO)
  22 + private Integer id;
  23 +
  24 + /**
  25 + * 商品名称
  26 + */
  27 + @TableField(value = "name")
  28 + private String name;
  29 +
  30 + /**
  31 + * 价格 单位分
  32 + */
  33 + @TableField(value = "price")
  34 + private Integer price;
  35 +
  36 + /**
  37 + * 单位 (天)单次商品服务时长
  38 + */
  39 + @TableField(value = "time_limit")
  40 + private Integer timeLimit;
  41 +
  42 + /**
  43 + * 创建时间
  44 + */
  45 + @TableField(value = "createdtime")
  46 + private Date createdtime;
  47 +
  48 + @TableField(exist = false)
  49 + private static final long serialVersionUID = 1L;
  50 +
  51 + @Override
  52 + public boolean equals(Object that) {
  53 + if (this == that) {
  54 + return true;
  55 + }
  56 + if (that == null) {
  57 + return false;
  58 + }
  59 + if (getClass() != that.getClass()) {
  60 + return false;
  61 + }
  62 + LymsGroupGoods other = (LymsGroupGoods) that;
  63 + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
  64 + && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
  65 + && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
  66 + && (this.getTimeLimit() == null ? other.getTimeLimit() == null : this.getTimeLimit().equals(other.getTimeLimit()))
  67 + && (this.getCreatedtime() == null ? other.getCreatedtime() == null : this.getCreatedtime().equals(other.getCreatedtime()));
  68 + }
  69 +
  70 + @Override
  71 + public int hashCode() {
  72 + final int prime = 31;
  73 + int result = 1;
  74 + result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
  75 + result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
  76 + result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
  77 + result = prime * result + ((getTimeLimit() == null) ? 0 : getTimeLimit().hashCode());
  78 + result = prime * result + ((getCreatedtime() == null) ? 0 : getCreatedtime().hashCode());
  79 + return result;
  80 + }
  81 +
  82 + @Override
  83 + public String toString() {
  84 + StringBuilder sb = new StringBuilder();
  85 + sb.append(getClass().getSimpleName());
  86 + sb.append(" [");
  87 + sb.append("Hash = ").append(hashCode());
  88 + sb.append(", id=").append(id);
  89 + sb.append(", name=").append(name);
  90 + sb.append(", price=").append(price);
  91 + sb.append(", timeLimit=").append(timeLimit);
  92 + sb.append(", createdtime=").append(createdtime);
  93 + sb.append(", serialVersionUID=").append(serialVersionUID);
  94 + sb.append("]");
  95 + return sb.toString();
  96 + }
  97 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsGroupOrder.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import java.io.Serializable;
  8 +import java.util.Date;
  9 +import java.util.List;
  10 +
  11 +import lombok.Data;
  12 +
  13 +/**
  14 + * 订单
  15 + * @TableName lyms_group_order
  16 + */
  17 +@TableName(value ="lyms_group_order")
  18 +@Data
  19 +public class LymsGroupOrder implements Serializable {
  20 + /**
  21 + * 主键id,自增
  22 + */
  23 + @TableId(value = "id", type = IdType.AUTO)
  24 + private Integer id;
  25 +
  26 + /**
  27 + * 订单编号
  28 + */
  29 + @TableField(value = "orderno")
  30 + private String orderno;
  31 +
  32 + /**
  33 + * 患者id
  34 + */
  35 + @TableField(value = "pid")
  36 + private Integer pid;
  37 +
  38 + /**
  39 + * 支付总价
  40 + */
  41 + @TableField(value = "total_prices")
  42 + private Integer totalPrices;
  43 +
  44 + /**
  45 + * 订单状态,订单生成(0),支付成功(1),处理完成(2),处理失败(-1)
  46 + */
  47 + @TableField(value = "status")
  48 + private Integer status;
  49 +
  50 + /**
  51 + * 支付订单号
  52 + */
  53 + @TableField(value = "payorderid")
  54 + private String payorderid;
  55 +
  56 + /**
  57 + * openid
  58 + */
  59 + @TableField(value = "openid")
  60 + private String openid;
  61 +
  62 + /**
  63 + * 支付时间
  64 + */
  65 + @TableField(value = "paytime")
  66 + private Date paytime;
  67 +
  68 + /**
  69 + * 创建时间
  70 + */
  71 + @TableField(value = "createdtime")
  72 + private Date createdtime;
  73 +
  74 + /**
  75 + * 更新时间
  76 + */
  77 + @TableField(value = "updatedtime")
  78 + private Date updatedtime;
  79 +
  80 + /**
  81 + * 订单量
  82 + */
  83 + @TableField(exist = false)
  84 + private List<LymsOrderData> orderData;
  85 +
  86 + @TableField(exist = false)
  87 + private static final long serialVersionUID = 1L;
  88 +
  89 + @Override
  90 + public boolean equals(Object that) {
  91 + if (this == that) {
  92 + return true;
  93 + }
  94 + if (that == null) {
  95 + return false;
  96 + }
  97 + if (getClass() != that.getClass()) {
  98 + return false;
  99 + }
  100 + LymsGroupOrder other = (LymsGroupOrder) that;
  101 + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
  102 + && (this.getOrderno() == null ? other.getOrderno() == null : this.getOrderno().equals(other.getOrderno()))
  103 + && (this.getPid() == null ? other.getPid() == null : this.getPid().equals(other.getPid()))
  104 + && (this.getTotalPrices() == null ? other.getTotalPrices() == null : this.getTotalPrices().equals(other.getTotalPrices()))
  105 + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
  106 + && (this.getPayorderid() == null ? other.getPayorderid() == null : this.getPayorderid().equals(other.getPayorderid()))
  107 + && (this.getOpenid() == null ? other.getOpenid() == null : this.getOpenid().equals(other.getOpenid()))
  108 + && (this.getPaytime() == null ? other.getPaytime() == null : this.getPaytime().equals(other.getPaytime()))
  109 + && (this.getCreatedtime() == null ? other.getCreatedtime() == null : this.getCreatedtime().equals(other.getCreatedtime()))
  110 + && (this.getUpdatedtime() == null ? other.getUpdatedtime() == null : this.getUpdatedtime().equals(other.getUpdatedtime()));
  111 + }
  112 +
  113 + @Override
  114 + public int hashCode() {
  115 + final int prime = 31;
  116 + int result = 1;
  117 + result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
  118 + result = prime * result + ((getOrderno() == null) ? 0 : getOrderno().hashCode());
  119 + result = prime * result + ((getPid() == null) ? 0 : getPid().hashCode());
  120 + result = prime * result + ((getTotalPrices() == null) ? 0 : getTotalPrices().hashCode());
  121 + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
  122 + result = prime * result + ((getPayorderid() == null) ? 0 : getPayorderid().hashCode());
  123 + result = prime * result + ((getOpenid() == null) ? 0 : getOpenid().hashCode());
  124 + result = prime * result + ((getPaytime() == null) ? 0 : getPaytime().hashCode());
  125 + result = prime * result + ((getCreatedtime() == null) ? 0 : getCreatedtime().hashCode());
  126 + result = prime * result + ((getUpdatedtime() == null) ? 0 : getUpdatedtime().hashCode());
  127 + return result;
  128 + }
  129 +
  130 + @Override
  131 + public String toString() {
  132 + StringBuilder sb = new StringBuilder();
  133 + sb.append(getClass().getSimpleName());
  134 + sb.append(" [");
  135 + sb.append("Hash = ").append(hashCode());
  136 + sb.append(", id=").append(id);
  137 + sb.append(", orderno=").append(orderno);
  138 + sb.append(", pid=").append(pid);
  139 + sb.append(", totalPrices=").append(totalPrices);
  140 + sb.append(", status=").append(status);
  141 + sb.append(", payorderid=").append(payorderid);
  142 + sb.append(", openid=").append(openid);
  143 + sb.append(", paytime=").append(paytime);
  144 + sb.append(", createdtime=").append(createdtime);
  145 + sb.append(", updatedtime=").append(updatedtime);
  146 + sb.append(", serialVersionUID=").append(serialVersionUID);
  147 + sb.append("]");
  148 + return sb.toString();
  149 + }
  150 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsOrderData.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import java.io.Serializable;
  8 +import java.util.Date;
  9 +import lombok.Data;
  10 +
  11 +/**
  12 + * 订单量
  13 + * @TableName lyms_order_data
  14 + */
  15 +@TableName(value ="lyms_order_data")
  16 +@Data
  17 +public class LymsOrderData implements Serializable {
  18 + /**
  19 + * 主键id,自增
  20 + */
  21 + @TableId(value = "id", type = IdType.AUTO)
  22 + private Integer id;
  23 +
  24 + /**
  25 + * 商品id
  26 + */
  27 + @TableField(value = "gid")
  28 + private Integer gid;
  29 +
  30 + /**
  31 + * 订单数量
  32 + */
  33 + @TableField(value = "order_num")
  34 + private Integer orderNum;
  35 +
  36 + /**
  37 + * 订单id
  38 + */
  39 + @TableField(value = "order_id")
  40 + private Integer orderId;
  41 +
  42 + /**
  43 + * 本订单服务开始时间(从支付成功计时)
  44 + */
  45 + @TableField(value = "start_time")
  46 + private Date startTime;
  47 +
  48 + /**
  49 + * 本订单服务结束时间
  50 + */
  51 + @TableField(value = "end_time")
  52 + private Date endTime;
  53 +
  54 + /**
  55 + * 更新时间
  56 + */
  57 + @TableField(value = "updatedtime")
  58 + private Date updatedtime;
  59 +
  60 + /**
  61 + * 创建时间
  62 + */
  63 + @TableField(value = "createdtime")
  64 + private Date createdtime;
  65 +
  66 + @TableField(exist = false)
  67 + private static final long serialVersionUID = 1L;
  68 +
  69 + @Override
  70 + public boolean equals(Object that) {
  71 + if (this == that) {
  72 + return true;
  73 + }
  74 + if (that == null) {
  75 + return false;
  76 + }
  77 + if (getClass() != that.getClass()) {
  78 + return false;
  79 + }
  80 + LymsOrderData other = (LymsOrderData) that;
  81 + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
  82 + && (this.getGid() == null ? other.getGid() == null : this.getGid().equals(other.getGid()))
  83 + && (this.getOrderNum() == null ? other.getOrderNum() == null : this.getOrderNum().equals(other.getOrderNum()))
  84 + && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
  85 + && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
  86 + && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()))
  87 + && (this.getUpdatedtime() == null ? other.getUpdatedtime() == null : this.getUpdatedtime().equals(other.getUpdatedtime()))
  88 + && (this.getCreatedtime() == null ? other.getCreatedtime() == null : this.getCreatedtime().equals(other.getCreatedtime()));
  89 + }
  90 +
  91 + @Override
  92 + public int hashCode() {
  93 + final int prime = 31;
  94 + int result = 1;
  95 + result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
  96 + result = prime * result + ((getGid() == null) ? 0 : getGid().hashCode());
  97 + result = prime * result + ((getOrderNum() == null) ? 0 : getOrderNum().hashCode());
  98 + result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
  99 + result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
  100 + result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode());
  101 + result = prime * result + ((getUpdatedtime() == null) ? 0 : getUpdatedtime().hashCode());
  102 + result = prime * result + ((getCreatedtime() == null) ? 0 : getCreatedtime().hashCode());
  103 + return result;
  104 + }
  105 +
  106 + @Override
  107 + public String toString() {
  108 + StringBuilder sb = new StringBuilder();
  109 + sb.append(getClass().getSimpleName());
  110 + sb.append(" [");
  111 + sb.append("Hash = ").append(hashCode());
  112 + sb.append(", id=").append(id);
  113 + sb.append(", gid=").append(gid);
  114 + sb.append(", orderNum=").append(orderNum);
  115 + sb.append(", orderId=").append(orderId);
  116 + sb.append(", startTime=").append(startTime);
  117 + sb.append(", endTime=").append(endTime);
  118 + sb.append(", updatedtime=").append(updatedtime);
  119 + sb.append(", createdtime=").append(createdtime);
  120 + sb.append(", serialVersionUID=").append(serialVersionUID);
  121 + sb.append("]");
  122 + return sb.toString();
  123 + }
  124 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsGroupGoodsMapper.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsGroupGoods;
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +
  6 +/**
  7 + * @Entity com.lyms.talkonlineweb.domain.LymsGroupGoods
  8 + */
  9 +public interface LymsGroupGoodsMapper extends BaseMapper<LymsGroupGoods> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsGroupOrderMapper.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsGroupOrder;
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +
  6 +/**
  7 + * @Entity com.lyms.talkonlineweb.domain.LymsGroupOrder
  8 + */
  9 +public interface LymsGroupOrderMapper extends BaseMapper<LymsGroupOrder> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsOrderDataMapper.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsOrderData;
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +
  6 +/**
  7 + * @Entity com.lyms.talkonlineweb.domain.LymsOrderData
  8 + */
  9 +public interface LymsOrderDataMapper extends BaseMapper<LymsOrderData> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsGroupGoodsService.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsGroupGoods;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +
  6 +/**
  7 + *
  8 + */
  9 +public interface LymsGroupGoodsService extends IService<LymsGroupGoods> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsGroupOrderService.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsGroupOrder;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +
  6 +/**
  7 + *
  8 + */
  9 +public interface LymsGroupOrderService extends IService<LymsGroupOrder> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsOrderDataService.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsOrderData;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +
  6 +/**
  7 + *
  8 + */
  9 +public interface LymsOrderDataService extends IService<LymsOrderData> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsGroupGoodsServiceImpl.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.LymsGroupGoods;
  5 +import com.lyms.talkonlineweb.service.LymsGroupGoodsService;
  6 +import com.lyms.talkonlineweb.mapper.LymsGroupGoodsMapper;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +/**
  10 + *
  11 + */
  12 +@Service
  13 +public class LymsGroupGoodsServiceImpl extends ServiceImpl<LymsGroupGoodsMapper, LymsGroupGoods>
  14 + implements LymsGroupGoodsService{
  15 +
  16 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsGroupOrderServiceImpl.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.LymsGroupOrder;
  5 +import com.lyms.talkonlineweb.service.LymsGroupOrderService;
  6 +import com.lyms.talkonlineweb.mapper.LymsGroupOrderMapper;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +/**
  10 + *
  11 + */
  12 +@Service
  13 +public class LymsGroupOrderServiceImpl extends ServiceImpl<LymsGroupOrderMapper, LymsGroupOrder>
  14 + implements LymsGroupOrderService{
  15 +
  16 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsOrderDataServiceImpl.java View file @ fe51308
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.LymsOrderData;
  5 +import com.lyms.talkonlineweb.service.LymsOrderDataService;
  6 +import com.lyms.talkonlineweb.mapper.LymsOrderDataMapper;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +/**
  10 + *
  11 + */
  12 +@Service
  13 +public class LymsOrderDataServiceImpl extends ServiceImpl<LymsOrderDataMapper, LymsOrderData>
  14 + implements LymsOrderDataService{
  15 +
  16 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/StringUtil.java View file @ fe51308
... ... @@ -51,7 +51,21 @@
51 51 {
52 52 try
53 53 {
54   - return String.format("%s%s%06d", "D", DateUtil.getSeqString(), IdWorker.getFlowIdWorkerInstance().nextId());
  54 + return String.format("%s%s%06d", "LYMS", DateUtil.getSeqString(), IdWorker.getFlowIdWorkerInstance().nextId());
  55 + }catch (Exception e){
  56 +
  57 + }
  58 + return "";
  59 + }
  60 + /**
  61 + * 微信用生成一个唯一编号
  62 + * @return
  63 + */
  64 + public static String getUniqueWeixNo()
  65 + {
  66 + try
  67 + {
  68 + return String.format("%s%s%06d", "WEIX", DateUtil.getSeqString(), IdWorker.getFlowIdWorkerInstance().nextId());
55 69 }catch (Exception e){
56 70  
57 71 }
talkonlineweb/src/main/resources/application-dev.yml View file @ fe51308
... ... @@ -33,6 +33,8 @@
33 33  
34 34 #微信支付通知地址
35 35 notify.url: https://dev-talk-api.healthbaby.com.cn/order/payNotify
  36 +#微信订单,终端ip
  37 +weixin.createIP: 119.90.57.26
36 38  
37 39 proxyIP:
38 40 proxyPort:
talkonlineweb/src/main/resources/application-prod.yml View file @ fe51308
... ... @@ -29,6 +29,8 @@
29 29  
30 30 #微信支付通知地址
31 31 notify.url: https://talk-api.healthbaby.com.cn/order/payNotify
  32 +#微信订单,终端ip
  33 +weixin.createIP: 119.90.43.68
32 34  
33 35 proxyIP:
34 36 proxyPort:
talkonlineweb/src/main/resources/mapper/LymsGroupGoodsMapper.xml View file @ fe51308
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsGroupGoodsMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsGroupGoods">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="name" column="name" jdbcType="VARCHAR"/>
  10 + <result property="price" column="price" jdbcType="INTEGER"/>
  11 + <result property="timeLimit" column="time_limit" jdbcType="INTEGER"/>
  12 + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
  13 + </resultMap>
  14 +
  15 + <sql id="Base_Column_List">
  16 + id,name,price,
  17 + time_limit,createdtime
  18 + </sql>
  19 +</mapper>
talkonlineweb/src/main/resources/mapper/LymsGroupOrderMapper.xml View file @ fe51308
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsGroupOrderMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsGroupOrder">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
  10 + <result property="pid" column="pid" jdbcType="INTEGER"/>
  11 + <result property="totalPrices" column="total_prices" jdbcType="INTEGER"/>
  12 + <result property="status" column="status" jdbcType="BOOLEAN"/>
  13 + <result property="payorderid" column="payorderid" jdbcType="VARCHAR"/>
  14 + <result property="openid" column="openid" jdbcType="VARCHAR"/>
  15 + <result property="paytime" column="paytime" jdbcType="TIMESTAMP"/>
  16 + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
  17 + <result property="updatedtime" column="updatedtime" jdbcType="TIMESTAMP"/>
  18 + </resultMap>
  19 +
  20 + <sql id="Base_Column_List">
  21 + id,orderno,pid,
  22 + total_prices,status,payorderid,
  23 + openid,paytime,createdtime,
  24 + updatedtime
  25 + </sql>
  26 +</mapper>
talkonlineweb/src/main/resources/mapper/LymsOrderDataMapper.xml View file @ fe51308
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsOrderDataMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsOrderData">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="gid" column="gid" jdbcType="INTEGER"/>
  10 + <result property="orderNum" column="order_num" jdbcType="INTEGER"/>
  11 + <result property="orderId" column="order_id" jdbcType="INTEGER"/>
  12 + <result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
  13 + <result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
  14 + <result property="updatedtime" column="updatedtime" jdbcType="TIMESTAMP"/>
  15 + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
  16 + </resultMap>
  17 +
  18 + <sql id="Base_Column_List">
  19 + id,gid,order_num,
  20 + order_id,start_time,end_time,
  21 + updatedtime,createdtime
  22 + </sql>
  23 +</mapper>