同步二维码

master
wangweijia 6 years ago
parent b7ce416b10
commit de20a76269

@ -1,10 +1,15 @@
package com.kiisoo.ic.synchronous.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.synchronous.service.PromotionCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
/**
* 广
@ -12,14 +17,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/promotion")
@Slf4j
public class PromotionCodeController {
public class PromotionCodeController extends BaseController {
@Autowired
private com.kiisoo.ic.synchronous.service.PromotionCodeService PromotionCodeService;
private PromotionCodeService promotionCodeService;
//参数类型0为门店账号1为内部员工导购2为其他
public void getShopPromotion(){
PromotionCodeService.getPromotion(0);
/**
* 广
*/
@RequestMapping(value = "/shop",method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getShopPromotion(){
promotionCodeService.getStaffPromotion();
return data(success());
}
public void getStaffPromotion(){}

@ -9,6 +9,7 @@ import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult;
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper;
import com.kiisoo.ic.store.bean.BsdShareCodeResponse;
import com.kiisoo.ic.store.constant.Constants;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.entity.PoiStoreStaff;
@ -18,13 +19,15 @@ import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
import com.kiisoo.ic.synchronous.entity.PromotionDO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.kiisoo.ic.employee.constant.Constants.DATABASE_CP_USER_ID_KEY;
import static com.kiisoo.ic.store.constant.Constants.BSD_REQ_QRCODE_TYPE_STORE;
@Service
public class PromotionCodeService {
@ -49,9 +52,8 @@ public class PromotionCodeService {
/**
*
* @param i
*/
public void getPromotion(int i) {
public void getPromotion() {
//找到所有店铺
List<PoiStore> shops = poiStoreDOMapper.selectList(null);
@ -59,25 +61,22 @@ public class PromotionCodeService {
List<Long> shopIds = new ArrayList<>();
shopIds.add(item.getId());
//找到是否有推广码
List<StoreUserDTO> cpUserStoreDO = privilageCpUserStoreDOMapper.selectCpUserByShops(shopIds);
if(cpUserStoreDO.size() == 0){
PromotionDO p = new PromotionDO();
p.setType("0");
p.setStoreNo(item.getCode());
//没有推广码则查询
HttpResult data = HttpClientUtil.httpPost("http://vtest.bsd.cn/BSD_WXAPP/qyWechat/getShareQRcode?token=TOKEN", JSON.toJSONString(p),getToken());
//http返回参数
if((boolean) JSONObject.parseObject(data.getMessage()).get("success")){
String url = JSONObject.parseObject(data.getMessage()).get("data").toString();
//排重---根据企业微信账号查询是否存在用户
PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO();
privilageCpUserDO.setQrCode(url);
int insert = privilageCpUserDOMapper.insert(privilageCpUserDO);
PrivilageCpUserStoreDO cpUserStore = new PrivilageCpUserStoreDO();
cpUserStore.setStoreId(item.getId());
cpUserStore.setCpUserId(privilageCpUserDO.getId());
privilageCpUserStoreDOMapper.insert(cpUserStore);
List<StoreUserDTO> privilageCpUserDO = privilageCpUserStoreDOMapper.selectCpUserByShops(shopIds);
if(privilageCpUserDO.size() > 0){
StoreUserDTO cpUserStore = privilageCpUserDO.get(0);
String qrCodeAction = cpUserStore.getQrCodeAction();
if(StringUtils.isBlank(qrCodeAction)){
try {
qrCodeAction = getQrCodeFromBSD(cpUserStore.getCpUserId(),BSD_REQ_QRCODE_TYPE_STORE,"0",item.getCode());
cpUserStore.setQrCodeAction(qrCodeAction);
PrivilageCpUserDO update = new PrivilageCpUserDO();
update.setId(cpUserStore.getUserId());
update.setQrCode(qrCodeAction);
privilageCpUserDOMapper.updateById(update);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ -86,6 +85,31 @@ public class PromotionCodeService {
});
}
/**
*
* @param cpUserId
* @param type
* @param state
* @param storeNo
* @return
* @throws Exception
*/
public String getQrCodeFromBSD(String cpUserId,String type,String state,String storeNo) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> params = new HashMap<>();
params.put("userId", cpUserId);
params.put("type", type);
params.put("state", state);
params.put("storeNo", storeNo);
String message = HttpClientUtil.httpPost("http://vtest.bsd.cn/BSD_WXAPP/qyWechat/getShareQRcode?token=" + MD5FileUtil.getMD5String("BOSIDENG" + sdf.format(new Date())), JSONObject.toJSONString(params)).getMessage();
JSONObject qrCodeJson = JSONObject.parseObject(message);
BsdShareCodeResponse bsdResponse = qrCodeJson.toJavaObject(BsdShareCodeResponse.class);
if (bsdResponse.getSuccess()){
return bsdResponse.getData();
}
return null;
}
/**
*

@ -190,6 +190,7 @@ public class OrganizationInit {
//排重---根据企业微信账号查询是否存在用户
PrivilageCpUserDO privilageCpUserDO = new PrivilageCpUserDO();
privilageCpUserDO.setCpUserId(v.getCustomerUserId());
privilageCpUserDO.setStatus(1);
int insert = privilageCpUserDOMapper.insert(privilageCpUserDO);
PrivilageCpUserStoreDO cpUserStore = new PrivilageCpUserStoreDO();
cpUserStore.setStoreId(shopId);

Loading…
Cancel
Save