发送ai配置

This commit is contained in:
wangshuai 2024-07-11 14:29:49 +08:00
parent a418ffcb12
commit 4410a4fbb3
7 changed files with 38 additions and 23 deletions

View File

@ -80,7 +80,7 @@ public class BusBanOperateController extends BaseController
/**
* 新增免运营订单信息
*/
@PreAuthorize("@ss.hasPermi('system:info:add')")
// @PreAuthorize("@ss.hasPermi('system:info:add')")
@Log(title = "免运营订单信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ReqBusOrderList reqBusOrderList)

View File

@ -87,19 +87,10 @@ public class RyTask {
if("2".equals(busStoreInfo.getReturnVisitStatus())){
continue;// 未开启营销的跳出
}
BusAgentInfo agentInfo = new BusAgentInfo();
agentInfo.setAgentAccount(busStoreInfo.getBindUser());
List<BusAgentInfo> agentInfoL = agentInfoService.selectBusAgentInfoList(agentInfo);
if (agentInfoL.size() > 0) {
if (agentInfoL.get(0).getAiDurationBalance() <= 0) {
continue;//代理账分不足跳出
}
} else continue;
// 配置规则
BusStoreConfigInfo busStoreConfigInfo = new BusStoreConfigInfo();
busStoreConfigInfo.setStoreCode(busStoreInfo.getStoreCode());
busStoreConfigInfo = iBusStoreConfigInfoService.selectBusStoreConfigInfoList(busStoreConfigInfo).get(0);
redisTemplate.opsForValue().set(busStoreConfigInfo.getStoreCode()+now.format(dateTimeFormatterNow), busStoreConfigInfo.getQuota()+"");
List<BusOrderInfo> list = new ArrayList<>();
if("1".equals(busStoreInfo.getSelfDeliveryStatus())){
@ -110,7 +101,17 @@ public class RyTask {
// 自配送前推时间处理
list = orderInfoService.selectBusZpsOrderInfoListToAi(busStoreInfo.getStoreCode(), time);
}
if (list.size() == 0 ) continue;
list.forEach(System.out::println);
//代理账分不足跳出 取最小值
BusAgentInfo agentInfo = new BusAgentInfo();
agentInfo.setAgentAccount(busStoreInfo.getBindUser());
List<BusAgentInfo> agentInfoL = agentInfoService.selectBusAgentInfoList(agentInfo);
if (agentInfoL.size() > 0) {
if (agentInfoL.get(0).getAiDurationBalance() < list.size()) {
list.subList(0,agentInfoL.get(0).getAiDurationBalance()-1);
}
} else continue;
for (BusOrderInfo busOrderInfo : list) {
// 拼好饭
if("N".equals(busStoreConfigInfo.getIsSpliceOrder())){ // 开启拼好饭订单过滤(不营销拼好饭)
@ -159,21 +160,19 @@ public class RyTask {
continue;
}
// 当日此店铺营销限额
int quota = Integer.valueOf(redisTemplate.opsForValue().get(busStoreConfigInfo.getStoreCode()+now.format(dateTimeFormatterNow)));
if(quota==0){
int quota = iBusReturnVisitInfoService.countByToday(storeInfo.getStoreCode());
if(quota >= busStoreConfigInfo.getQuota()){
break;
}
quota = quota-1;
redisTemplate.opsForValue().set(busStoreConfigInfo.getStoreCode()+now.format(dateTimeFormatterNow), quota+"");
BusFifteenInfo fifteenInfo = new BusFifteenInfo();
fifteenInfo.setCustomId(busOrderInfo.getCustomId());
List<BusFifteenInfo> listInfo = fifteenInfoService.selectBusFifteenInfoList(fifteenInfo);
if (listInfo.size() == 0) {
System.out.println("话术:"+content+"; order"+busOrderInfo.toString());
aiService.sendAiTask(content,busOrderInfo);
// aiService.sendAiTask(content,busOrderInfo);
}
}
redisTemplate.delete(busStoreConfigInfo.getStoreCode()+now.format(dateTimeFormatterNow));
}
}

View File

@ -64,4 +64,6 @@ public interface BusReturnVisitInfoMapper
int batchInsertVisit(@Param("ls") List<BusReturnVisitInfo> ls);
List<BusReturnVisitInfo> selectBusReturnVisitInfoListByDate(@Param("storeCode") String storeCode,@Param("date") String date);
int countByToday(String storeCode);
}

View File

@ -60,4 +60,6 @@ public interface IBusReturnVisitInfoService
public int deleteBusReturnVisitInfoById(Long id);
List<BusReturnVisitInfo> selectBusReturnVisitInfoListByDate(String storeCode, String date);
int countByToday(String storeCode);
}

View File

@ -95,4 +95,9 @@ public class BusReturnVisitInfoServiceImpl implements IBusReturnVisitInfoService
public List<BusReturnVisitInfo> selectBusReturnVisitInfoListByDate(String storeCode, String date) {
return busReturnVisitInfoMapper.selectBusReturnVisitInfoListByDate(storeCode,date);
}
@Override
public int countByToday(String storeCode) {
return busReturnVisitInfoMapper.countByToday(storeCode);
}
}

View File

@ -274,7 +274,7 @@ public class MeituanServiceImpl implements IMeituanService {
}
}
}
System.out.println(jsonObject);
// System.out.println(jsonObject);
return true;
}
@ -386,7 +386,7 @@ public class MeituanServiceImpl implements IMeituanService {
array = jo.getJSONObject("data").getJSONArray("wmOrderList");
} else {
System.out.println(jo.getString("msg"));
break;
return R.fail(jo.getString("msg"));
}
}
return R.ok();
@ -420,14 +420,16 @@ public class MeituanServiceImpl implements IMeituanService {
HttpClient client = proxyHttpClient();
HttpEntity responseEntity;
String resp;
String resp = null;
JSONObject jsonObject = new JSONObject();
try {
responseEntity = client.execute(httpPost).getEntity();
resp = EntityUtils.toString(responseEntity);
} catch (IOException e) {
throw new RuntimeException(e);
jsonObject = JSONObject.parseObject(resp);
} catch (Exception e) {
System.out.println(e.getMessage());
jsonObject.put("code","403");
}
JSONObject jsonObject = JSONObject.parseObject(resp);
return jsonObject;
}
@ -617,7 +619,7 @@ public class MeituanServiceImpl implements IMeituanService {
}
}
}
System.out.println(result);
// System.out.println(result);
return true;
}
@ -673,7 +675,7 @@ public class MeituanServiceImpl implements IMeituanService {
busStoreDayInfo1.setLastPositiveReviewsNum(fiveNum + fourNum);
busStoreDayInfoService.updateBusStoreDayInfo(busStoreDayInfo1);
}
System.out.println(jsonObject);//落库
// System.out.println(jsonObject);//落库
return true;
} catch (Exception e) {
System.out.println(e.getMessage());

View File

@ -41,6 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="date != null "> and DATE_FORMAT(return_visit_time,'%Y-%m-%d') = #{date}</if>
</where>
</select>
<select id="countByToday" resultType="java.lang.Integer">
select count(id) from bus_return_visit_info
where date_format(return_visit_time,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
<if test="storeCode != null and storeCode != ''"> and store_code = #{storeCode}</if>
</select>
<insert id="batchInsertVisit">
insert into bus_return_visit_info (store_code,store_name,phone_number,phone_end_number,return_visit_time) values