Browse Source

2024年3月28日12:44:19

纪新园 1 năm trước cách đây
mục cha
commit
91089357af

+ 48 - 0
blade-service/blade-pay/src/main/java/org/springblade/pay/tonglianPayment/service/impl/PaymentServiceImpl.java

@@ -858,6 +858,9 @@ public class PaymentServiceImpl implements IPaymentService {
 
 					R<List<PjOrder>> re = ipjOrderClient.getByOrder(order);
 					if (re.isSuccess() && ObjectUtils.isNotNull(re.getData())) {
+						StringBuilder openIds = new StringBuilder();
+						String serialNumber = re.getData().get(0).getSrcOrdNo();
+						BigDecimal amount = new BigDecimal("0.00");
 						for (PjOrder selectOrder : re.getData()) {
 							selectOrder.setPaymentDate(new Date());
 							selectOrder.setActualPaymentStatus(2);
@@ -867,6 +870,7 @@ public class PaymentServiceImpl implements IPaymentService {
 							wechatMark.setBillNo(selectOrder.getOrdNo());
 							wechatMark.setSalesCompanyId(selectOrder.getSalesCompanyId());
 							wechatMark.setSalesCompanyName(selectOrder.getSalesCompanyName());
+							amount = amount.add(selectOrder.getPaymentAmountTl());
 							ipjOrderClient.updateBySrcOrgId(selectOrder.getId() + "");
 							LocalDateTime now = LocalDateTime.now();
 							DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -880,6 +884,9 @@ public class PaymentServiceImpl implements IPaymentService {
 								R<List<User>> userList = userClient.listUserByRoleId(clientDeptIds.getData(), parametersDetails.getTenantId(), selectOrder.getSalesCompanyId() + "");
 								if (userList.isSuccess() && CollectionUtils.isNotEmpty(userList.getData())) {
 									for (User datum : userList.getData()) {
+										if (ObjectUtils.isNotNull(datum.getOaOpenId())) {
+											openIds.append(datum.getOaOpenId()).append(",");
+										}
 										//循环发送消息
 										Message sendMessage = new Message();
 										sendMessage.setParameter(selectOrder.getId() + "");
@@ -933,6 +940,47 @@ public class PaymentServiceImpl implements IPaymentService {
 						} else {
 							System.out.println("积分修改失败调取接口异常");
 						}
+						SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
+						String date1 = format.format(new Date());
+
+						System.out.println("=========发送人openIds=========" + openIds);
+						if (ObjectUtils.isNotNull(openIds)) {
+							PjOrder pjOrder = re.getData().get(0);
+							pjOrder.setDate(date1);
+							pjOrder.setAmount(amount.toString());
+							R<List<WechatMessageConfigurationItem>> resItem = wechatClient.getTemplateType("2", re.getData().isEmpty() ? "" : re.getData().get(0).getTenantId());
+							if (resItem.isSuccess() && ObjectUtils.isNotNull(resItem.getData())) {
+								List<WxMpTemplateData> data = new ArrayList<>();
+								if (ObjectUtils.isNotNull(pjOrder.getSalerName()) && pjOrder.getSalerName().length() > 3) {
+									pjOrder.setSalerName(pjOrder.getSalerName().substring(0, 3));
+								}
+								for (WechatMessageConfigurationItem item : resItem.getData()) {
+									try {
+										// 根据方法名获取对应的Method对象
+										Method method = pjOrder.getClass().getMethod(item.getMethod());
+										// 调用get方法并打印结果
+										Object result = method.invoke(pjOrder);
+										System.out.println(result);
+										if (ObjectUtils.isNotNull(result)) {
+											data.add(new WxMpTemplateData(item.getDataValue(), result.toString()));
+										} else {
+											data.add(new WxMpTemplateData(item.getDataValue(), "无"));
+										}
+									} catch (Exception e) {
+										e.printStackTrace();
+									}
+								}
+								if (!data.isEmpty()) {
+									WxMpTemplateDto wxMpTemplateDto = new WxMpTemplateDto();
+									wxMpTemplateDto.setOpenid(openIds.substring(0, openIds.length() - 1));
+									wxMpTemplateDto.setTenantId(re.getData().isEmpty() ? "" : re.getData().get(0).getTenantId());
+									wxMpTemplateDto.setType("2");
+									wxMpTemplateDto.setData(data);
+									String rest = wechatClient.sendMessageNew(wxMpTemplateDto);
+									System.out.println("=========发送返回值=========" + rest);
+								}
+							}
+						}
 						wechatMark.setCause("订单" + AnalysisMapUtils.getString("cusorderid", params) + "支付成功");
 						wechatMark.setStatus(1);
 					} else {

+ 59 - 1
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/corps/service/impl/CorpsDescServiceImpl.java

@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import io.seata.spring.annotation.GlobalTransactional;
 import lombok.AllArgsConstructor;
+import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
 import org.springblade.client.entity.CorpsDesc;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
@@ -45,10 +46,15 @@ import org.springblade.system.user.entity.User;
 import org.springblade.system.user.entity.UserInfo;
 import org.springblade.system.user.enums.UserEnum;
 import org.springblade.system.user.feign.IUserClient;
+import org.springblade.weChat.feign.IWechatClient;
+import org.springblade.weChat.message.dto.WxMpTemplateDto;
+import org.springblade.weChat.message.entity.WechatMessageConfigurationItem;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import java.lang.reflect.Method;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -77,6 +83,8 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 	private final IUserClient userClient;
 	private final ISysClient sysClient;
 
+	private final IWechatClient wechatClient;
+
 
 	static final int GB_SP_DIFF = 160;
 	// 存放国标一级汉字不同读音的起始区位码
@@ -985,7 +993,57 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
 				corpsDesc.setUpdateUser(AuthUtil.getUserId());
 				baseMapper.updateById(corpsDesc);
 			}
-
+		}
+		PjShip item = new PjShip();
+		//给角色为财务的人发送消息
+		R<String> clientDeptIds = sysClient.getRoleIds(AuthUtil.getTenantId(), "客服");
+		StringBuilder openIds = new StringBuilder();
+		if (clientDeptIds.isSuccess() && StringUtils.isNotBlank(clientDeptIds.getData())) {
+			R<List<User>> userList = userClient.listUserByRoleId(clientDeptIds.getData(), AuthUtil.getTenantId(), AuthUtil.getDeptId());
+			if (userList.isSuccess() && CollectionUtils.isNotEmpty(userList.getData())) {
+				for (User datum : userList.getData()) {
+					if (ObjectUtils.isNotNull(datum.getOaOpenId())) {
+						openIds.append(datum.getOaOpenId()).append(",");
+					}
+				}
+			}
+		}
+		SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
+		String date1 = format.format(new Date());
+		System.out.println("=========发送人openIds=========" + openIds);
+		if (ObjectUtils.isNotNull(openIds)) {
+			R<List<WechatMessageConfigurationItem>> res = wechatClient.getTemplateType("1", AuthUtil.getTenantId());
+			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+				item.setDate(date1);
+				item.setGoodsNames("商品json");
+				item.setCustomerName("客户名称");
+				List<WxMpTemplateData> data = new ArrayList<>();
+				for (WechatMessageConfigurationItem items : res.getData()) {
+					try {
+						// 根据方法名获取对应的Method对象
+						Method method = item.getClass().getMethod(items.getMethod());
+						// 调用get方法并打印结果
+						Object result = method.invoke(item);
+						System.out.println(result);
+						if (ObjectUtils.isNotNull(result)) {
+							data.add(new WxMpTemplateData(items.getDataValue(), result.toString()));
+						} else {
+							data.add(new WxMpTemplateData(items.getDataValue(), "无"));
+						}
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+				if (!data.isEmpty()) {
+					WxMpTemplateDto wxMpTemplateDto = new WxMpTemplateDto();
+					wxMpTemplateDto.setOpenid(openIds.substring(0, openIds.length() - 1));
+					wxMpTemplateDto.setTenantId(AuthUtil.getTenantId());
+					wxMpTemplateDto.setType("1");
+					wxMpTemplateDto.setData(data);
+					String rest = wechatClient.sendMessageNew(wxMpTemplateDto);
+					System.out.println("=========发送返回值=========" + rest);
+				}
+			}
 		}
 		return R.data(corpsDesc);
 	}

+ 15 - 3
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/productLaunch/service/impl/ProductLaunchServiceImpl.java

@@ -297,7 +297,11 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
 
 				List<PjStockDesc> stockDescList = pjStockDescList.stream().filter(i -> i.getGoodsId().equals(pjGoodsDesc.getId())).collect(Collectors.toList());
 				if ("1".equals(status)) {
-					productLaunch.setInventory(BigDecimal.ZERO);
+					if (!stockDescList.isEmpty()) {
+						productLaunch.setInventory(stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+					} else {
+						productLaunch.setInventory(BigDecimal.ZERO);
+					}
 				} else {
 					if (!stockDescList.isEmpty()) {
 						if (new BigDecimal("0.00").compareTo(stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)) == 0) {
@@ -784,7 +788,11 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
 
 				List<PjStockDesc> stockDescList = pjStockDescList.stream().filter(i -> i.getGoodsId().equals(pjGoodsDesc.getId())).collect(Collectors.toList());
 				if ("1".equals(status)) {
-					productLaunch.setInventory(BigDecimal.ZERO);
+					if (!stockDescList.isEmpty()) {
+						productLaunch.setInventory(stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+					} else {
+						productLaunch.setInventory(BigDecimal.ZERO);
+					}
 				} else {
 					if (!stockDescList.isEmpty()) {
 						if (new BigDecimal("0.00").compareTo(stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)) == 0) {
@@ -1015,7 +1023,11 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
 
 				List<PjStockDesc> stockDescList = pjStockDescList.stream().filter(i -> i.getGoodsId().equals(pjGoodsDesc.getId())).collect(Collectors.toList());
 				if ("1".equals(status)) {
-					productLaunch.setInventory(BigDecimal.ZERO);
+					if (!stockDescList.isEmpty()) {
+						productLaunch.setInventory(stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+					} else {
+						productLaunch.setInventory(BigDecimal.ZERO);
+					}
 				} else {
 					if (!stockDescList.isEmpty()) {
 						if (new BigDecimal("0.00").compareTo(stockDescList.stream().map(PjStockDesc::getBalanceQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)) == 0) {

+ 2 - 5
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/stock/mapper/StockDescMapper.xml

@@ -177,14 +177,11 @@
         LEFT JOIN pjpf_stock_desc stock ON goods.id = stock.goods_id
         <where>
             goods.is_deleted = 0
-            <if test="stockDesc.whether == null or stockDesc.whether == '' or stockDesc.whether == '0'">
+            <if test='stockDesc.whether != null and stockDesc.whether != "" and stockDesc.whether == "0"'>
                 and stock.balance_quantity != 0
             </if>
-            <if test="stockDesc.brandId != null and stockDesc.brandId != ''">
-                and goods.brand_id = #{stockDesc.brandId}
-            </if>
             <if test='stockDesc.cname != null and stockDesc.cname != ""'>
-                and goods.cname like CONCAT(CONCAT('%', #{stockDesc.cname}), '%')
+                and (goods.cname like CONCAT(CONCAT('%', #{stockDesc.cname}), '%') or goods.cname_int like CONCAT(CONCAT('%', #{stockDesc.cname}), '%'))
             </if>
             <if test='stockDesc.code != null and stockDesc.code != ""'>
                 and goods.code like CONCAT(CONCAT('%', #{stockDesc.code}), '%')