|
@@ -13,6 +13,7 @@ import com.caimei.modules.order.entity.*;
|
|
|
import com.caimei.modules.order.utils.HttpClientUtils;
|
|
|
import com.caimei.modules.order.utils.NewOrderStatus;
|
|
|
import com.caimei.modules.order.utils.OrderUtil;
|
|
|
+import com.caimei.modules.order.utils.RandomCode;
|
|
|
import com.caimei.modules.product.dao.CmPromotionDao;
|
|
|
import com.caimei.modules.product.dao.CmSecondHandDetailDao;
|
|
|
import com.caimei.modules.product.dao.ProductDao;
|
|
@@ -47,6 +48,8 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
@@ -351,6 +354,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
newOrderProduct.setOrderID(newOrder.getOrderID());
|
|
|
List<NewOrderProduct> dbOrderProducts = newOrderProductDao.findAllList(newOrderProduct);
|
|
|
|
|
|
+ StringBuilder productName = new StringBuilder();
|
|
|
if (flag) {
|
|
|
//新增加的订单,那么删除原有的子订单 和订单商品信息
|
|
|
newOrderProductDao.deleteByOrderID(newOrder.getOrderID());
|
|
@@ -370,6 +374,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
double shopReducedPrice = 0d;
|
|
|
double needPayAmount = shopOrder.getNeedPayAmount();
|
|
|
for (NewOrderProduct orderProduct : shopOrder.getNewOrderProducts()) {
|
|
|
+ productName.append(orderProduct.getName());
|
|
|
// 没有折扣时促销才生效
|
|
|
if (orderProduct.getDiscount() >= 100d) {
|
|
|
if (null != promotionsList && promotionsList.size() > 0) {
|
|
@@ -641,10 +646,68 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
}
|
|
|
newOrder.setShopOrderIDs(shopOrderIDs);
|
|
|
newOrderDao.update(newOrder);
|
|
|
+
|
|
|
+ //下单短信推送
|
|
|
+ try {
|
|
|
+ if (flag) {
|
|
|
+ CmUser user = cmUserDao.get(newOrder.getUserID().toString());
|
|
|
+ if (user != null && StringUtils.isNotBlank(user.getBindMobile())) {
|
|
|
+ String wwwServer = Global.getConfig("wwwServer");
|
|
|
+ String shortLink = getShortLink(8, 3, wwwServer + "user/order/detail.html?orderId=" + newOrder.getOrderID());
|
|
|
+ String name = productName.toString();
|
|
|
+ if (name.length() > 10) {
|
|
|
+ name = name.substring(0, 10);
|
|
|
+ }
|
|
|
+ String content = "您已成功下单“" + name + "...”等" + newOrder.getProductCount() + "件商品,订单编号:" + newOrder.getOrderNo() + ",订单等待支付,支付完成后采美将尽快安排发货。" +
|
|
|
+ "您可关注采美公众号或者访问采美微信小程序和网站查看并支付订单。平台公众号:微信搜索“采美365网”; 微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
|
|
|
+ boolean sendSms = getSendSms(3, user.getBindMobile(), content);
|
|
|
+ if (!sendSms) {
|
|
|
+ logger.info("下单推送失败,orderId>>>>" + newOrder.getOrderID());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public String getShortLink(int length, int markId, String url) {
|
|
|
+ String shortLink = RandomCode.generateShortLink(length);
|
|
|
+ Integer id = newOrderDao.findBYShortLink(shortLink);
|
|
|
+ if (id != null && id > 0) {
|
|
|
+ getShortLink(length, markId, url);
|
|
|
+ }
|
|
|
+ newOrderDao.insertShortLink(markId, shortLink, url);
|
|
|
+ return shortLink;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean getSendSms(int markId, String mobile, String content) throws Exception {
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
|
|
|
+ String regex = "^(1[3-9]\\d{9}$)";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(mobile);
|
|
|
+ if (matcher.matches()) {
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
+ map.put("content", content);
|
|
|
+ map.put("mobile", mobile);
|
|
|
+ String coreServer = Global.getConfig("caimei.core");
|
|
|
+ String url = coreServer + "/tools/sms/send";
|
|
|
+ String result = HttpRequest.sendPost(url, map);
|
|
|
+ JSONObject parseObject = JSONObject.parseObject(result);
|
|
|
+ Integer code = parseObject.getInteger("code");
|
|
|
+ if (code != 0) {
|
|
|
+ logger.info("短信发送失败,手机号>>>>" + mobile);
|
|
|
+ } else {
|
|
|
+ newOrderDao.updateSendNum(markId, 1);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private void insertLadderPrice(NewOrderProduct orderProduct) {
|
|
|
List<OrderProductLadderPrice> orderProductLadderPriceList = new ArrayList<>();
|
|
|
if (orderProduct.getLadderPriceFlag() == 1) {
|
|
@@ -1175,6 +1238,21 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
int userBeans = user.getUserBeans() + order.getUserBeans();
|
|
|
cmUserDao.updateUserBeans(order.getUserID(), userBeans);
|
|
|
}
|
|
|
+ //取消订单短信推送
|
|
|
+ try {
|
|
|
+ if (user != null && StringUtils.isNotBlank(user.getBindMobile())) {
|
|
|
+ String wwwServer = Global.getConfig("wwwServer");
|
|
|
+ String shortLink = getShortLink(8, 11, wwwServer + "user/order/detail.html?orderId=" + orderID);
|
|
|
+ String content = "您已成功取消订单(订单编号:" + order.getOrderNo() + "),订单金额¥" + order.getPayTotalFee() + "。您可关注采美公众号或者访问采美微信小程序和网站查看订单。" +
|
|
|
+ "平台公众号:微信搜索“采美365网”; 微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
|
|
|
+ boolean sendSms = getSendSms(11, user.getBindMobile(), content);
|
|
|
+ if (!sendSms) {
|
|
|
+ logger.info("取消订单推送失败,订单id>>>>" + orderID);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1260,6 +1338,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
}
|
|
|
//同步更新主订单的发货状态
|
|
|
NewOrder order = newOrderDao.findByOrderID(orderID);
|
|
|
+ String sendOutStatus = order.getSendOutStatus();
|
|
|
List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(order.getOrderID());
|
|
|
|
|
|
String statusSuffix = "";
|
|
@@ -1333,6 +1412,33 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
|
|
|
logisticsInformationDao.insert(l);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ try {
|
|
|
+ //发货短信推送
|
|
|
+ CmUser user = cmUserDao.get(order.getUserID().toString());
|
|
|
+ if (user != null && StringUtils.isNotBlank(user.getBindMobile())) {
|
|
|
+ String wwwServer = Global.getConfig("wwwServer");
|
|
|
+ boolean sendSms = false;
|
|
|
+ if ("2".equals(order.getSendOutStatus()) && "1".equals(sendOutStatus)) {
|
|
|
+ //部分发货
|
|
|
+ String shortLink = getShortLink(8, 7, wwwServer + "user/order/detail.html?orderId=" + order.getOrderID());
|
|
|
+ String content = "您的订单(订单编号:" + order.getOrderNo() + ")已部分发货。您可关注采美公众号或者访问采美微信小程序和网站查看订单。平台公众号:微信搜索“采美365网”; " +
|
|
|
+ "微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
|
|
|
+ sendSms = getSendSms(7, user.getBindMobile(), content);
|
|
|
+ } else if ("3".equals(order.getSendOutStatus())) {
|
|
|
+ //已发货
|
|
|
+ String shortLink = getShortLink(8, 8, wwwServer + "user/order/detail.html?orderId=" + order.getOrderID());
|
|
|
+ String content = "您的订单(订单编号:" + order.getOrderNo() + ")已发货完毕。您可关注采美公众号或者访问采美微信小程序和网站查看订单。平台公众号:微信搜索“采美365网”; " +
|
|
|
+ "微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
|
|
|
+ sendSms = getSendSms(8, user.getBindMobile(), content);
|
|
|
+ }
|
|
|
+ if (!sendSms) {
|
|
|
+ logger.info("发货短信推送失败,订单id>>>>" + order.getOrderID());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
return lb.getId();
|
|
|
}
|
|
|
|