Commit c80b825a authored by 谢希宇's avatar 谢希宇

Aidea product update by Strive Date 2020-11-12

parent c799f851
......@@ -197,24 +197,25 @@
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
<select id="consultSheetList" resultType="com.cftech.consultsheet.model.ConsultSheet">
SELECT
<include refid="sqlCol"/>
<include refid="sqlCol"/>
from t_aidea_consult_sheet
where del_flag = 0
<if test="openid!=null">
and open_id = #{openid}
</if>
<if test="name!=null and name !=''">
and user_name like concat('%',#{name},'%')
</if>
<if test="id!=null">
and id = #{id}
</if>
ORDER BY create_time DESC
<if test="page!=null and pageSize !='' and pageSize!=null and page !=''">
limit #{page},#{pageSize}
</if>
<if test="openid!=null">
and open_id = #{openid}
</if>
<if test="name!=null and name !=''">
and CONVERT(AES_DECRYPT(user_name,'aideakey') USING UTF8) like concat('%',#{name},'%')
</if>
<if test="id!=null">
and id = #{id}
</if>
ORDER BY create_time DESC
<if test="page!=null and pageSize !='' and pageSize!=null and page !=''">
limit #{page}, #{pageSize}
</if>
</select>
<update id="update" parameterType="com.cftech.consultsheet.model.ConsultSheet">
......
package com.cftech.consultsheet.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cftech.accounts.model.MpAccountsEntity;
import com.cftech.accounts.service.MpAccountsService;
import com.cftech.base.codingrule.utils.CodingruleUtils;
import com.cftech.base.org.api.QyMediaUtil;
import com.cftech.base.org.api.QyMsgUtil;
import com.cftech.base.org.model.Qyuser;
import com.cftech.base.org.service.QyuserService;
......@@ -18,11 +20,14 @@ import com.cftech.core.scope.OrderType;
import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort;
import com.cftech.core.util.Constants;
import com.cftech.core.util.MpTokenUtil;
import com.cftech.core.util.StringUtils;
import com.cftech.core.util.SystemConfig;
import com.cftech.cos.config.cosconfig.model.Cosconfig;
import com.cftech.member.model.Member;
import com.cftech.member.service.MemberService;
import com.cftech.order.service.OrderService;
import org.mp.api.wxbase.wxmedia.JwMediaAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -61,6 +66,12 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im
@Autowired
private CodingruleUtils codingruleUtils;
@Autowired
private MpTokenUtil mpTokenUtil;
@Autowired
private QyMediaUtil mediaUtil;
@Autowired
private QyMsgUtil qyMsgUtil;
......@@ -99,11 +110,22 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im
public JSONObject pollingConsultSheet(ConsultSheet consultSheet) {
JSONObject retObj = new JSONObject();
try {
MpAccountsEntity mpAccountsAppid = mpAccountsService.getMpAccountsAppid(consultSheet.getAppId());
MpAccountsEntity mpAccountsEntity = mpAccountsService.getMpAccountsAppid(consultSheet.getAppId());
consultSheet.setConsultId(codingruleUtils.getNumber(consultSheet.getAccountsId(), ConsultSheet.class.getName()));
//处理处方单图片
String fileName = mediaUtil.downloadMpMediaToDisk(mpAccountsEntity.getId(), "consultSheet", consultSheet.getPrescription());
String url = SystemConfig.p.getProperty("QY_DOMAIN") + SystemConfig.p.getProperty("IMAGEURL").replace("{PICFILENAME}", fileName);
consultSheet.setAccountsId(mpAccountsEntity.getId());
consultSheet.setPrescription(url);
if (consultSheetMapper.save(consultSheet) > 0) {
memberProcess(consultSheet.getOpenId(), consultSheet);
//展示客服二维码
Qyuser serviceCus = qyuserService.fetchById(consultSheet.getServiceId());
retObj.put("errorNo", 0);
retObj.put("data", serviceCus.getQrcode());
retObj.put("errorMsg", "咨询单提交成功,请等待药师审核");
} else {
retObj.put("errorNo", 1);
......@@ -292,8 +314,4 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im
agenId, msg, false);
}
@Scheduled(cron="*/5 * * * * ?")
public void dingshi() {
System.out.println("启动定时任务5秒一次");
}
}
\ No newline at end of file
......@@ -49,6 +49,5 @@ public class MobileConsultSheetController {
public void test(Long id) {
ConsultSheet consultSheet = consultSheetService.fetchById(id);
consultSheetService.sendQyWechatMassage(consultSheet);
}
}
......@@ -41,7 +41,7 @@ LOG_URL=http://www.michang-tech.com.cn:6989/log/addlog
#\u6821\u9A8C\u5151\u6362\u5BC6\u7801KEY
MEMBER_PASSWORD_KEY=DONGCHANGINT9527;
list.refreshtoken=true
jwt.domain=127.0.0.1
jwt.domain=pd.shxrtech.com
#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
jwt.duration=86400000
#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u03AAtrue
......
......@@ -5,6 +5,7 @@ import com.cftech.addresst.model.Address;
import com.cftech.addresst.model.AddressVO;
import com.cftech.addresst.model.Area;
import com.cftech.core.generic.GenericDao;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -30,7 +31,7 @@ public interface AddressMapper extends GenericDao<Address> {
* @Param
* @return
**/
List<AddressVO> addressList(String openId);
List<AddressVO> addressList(@Param("openId") String openId, @Param("addressId") Long addressId);
/**
* @Description 根据id查询收货地址
* @Date 9:53 2020/10/20
......
......@@ -127,57 +127,59 @@
)
</insert>
<select id="addressId" resultType="com.cftech.addresst.model.AddressVO">
select
select
t.id,
t.open_id as openId,
t.address_name as addressName,
t.address,
t.province_id as provinceId,
t.city_id as cityId,
t.area_id as areaId,
t.sex,
t.phone,
t.whether,
t.accounts_id as accountsId,
a.areaid,
a.citytype,
a.areaname provinceName,
b.areaname cityName,
c.areaname areaName
FROM
t_shipping_address t
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
and t.del_flag=0
WHERE t.id = #{id}
t.open_id as openId,
t.address_name as addressName,
t.address,
t.province_id as provinceId,
t.city_id as cityId,
t.area_id as areaId,
t.sex,
t.phone,
t.whether,
t.accounts_id as accountsId,
a.areaid,
a.citytype,
a.areaname provinceName,
b.areaname cityName,
c.areaname areaName
FROM
t_shipping_address t
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
and t.del_flag=0
WHERE t.id = #{id}
</select>
<select id="addressList" resultType="com.cftech.addresst.model.AddressVO">
SELECT
t.id,
t.open_id as openId,
t.address_name as addressName,
t.address,
t.province_id as provinceId,
t.city_id as cityId,
t.area_id as areaId,
t.sex,
t.phone,
t.whether,
t.accounts_id as accountsId,
a.areaid,
a.citytype,
a.areaname provinceName,
b.areaname cityName,
c.areaname areaName
FROM
t_shipping_address t
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
WHERE t.open_id = #{openId}
and t.del_flag=0
SELECT
t.id,
t.open_id as openId,
t.address_name as addressName,
t.address,
t.province_id as provinceId,
t.city_id as cityId,
t.area_id as areaId,
t.sex,
t.phone,
t.whether,
t.accounts_id as accountsId,
a.areaid,
a.citytype,
a.areaname provinceName,
b.areaname cityName,
c.areaname areaName
FROM
t_shipping_address t
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
WHERE t.open_id = #{openId}
AND t.del_flag=0
<if test="addressId != null and addressId != '' ">
AND t.id = #{addressId}
</if>
</select>
<select id="fetchById" parameterType="java.lang.Long" resultMap="resultMap">
......
......@@ -10,50 +10,55 @@ import java.io.Serializable;
import java.util.List;
/**
* 收货地址管理Service
*
* @author Licc
* @date: 2020-09-29 17:17
*/
* 收货地址管理Service
*
* @author Licc
* @date: 2020-09-29 17:17
*/
public interface AddressService extends GenericService<Address> {
List<Area> listArea();
/**
* @Description 个人收货地址数据回填
* @return
* @Description 个人收货地址数据回填
* @Date 9:53 2020/10/20
* @Param
* @return
**/
JSONObject addressList(String openId,String appId);
JSONObject addressList(String openId, String appId, Long addressId);
/**
* @Description 根据id查询收货地址
* @return
* @Description 根据id查询收货地址
* @Date 9:53 2020/10/20
* @Param
* @return
**/
JSONObject addressId(Long id,String appId);
JSONObject addressId(Long id, String appId);
/**
* @Description 个人收货地址新增
* @return
* @Description 个人收货地址新增
* @Date 9:53 2020/10/20
* @Param
* @return
**/
JSONObject addressAdd(Address address);
/**
* @return
* @Author Licc
* @Description 个人收货地址修改
* @Description 个人收货地址修改
* @Date 15:23 2020/10/20
* @Param
* @return
**/
JSONObject updateAddress(Address address);
/**
* @return
* @Author Licc
* @Description 个人收货地址删除
* @Description 个人收货地址删除
* @Date 15:53 2020/10/20
* @Param
* @return
**/
JSONObject deleteAddress(String id,String appId);
JSONObject deleteAddress(String id, String appId);
}
......@@ -51,7 +51,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
}
@Override
public JSONObject addressList(String openId, String appId) {
public JSONObject addressList(String openId, String appId, Long addressId) {
JSONObject rtnJson = new JSONObject();
try {
......@@ -61,7 +61,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
return rtnJson;
}
MpAccountsEntity mpAccountsAppid = mpAccountsService.getMpAccountsAppid(appId);
List<AddressVO> addressList = addressMapper.addressList(openId);
List<AddressVO> addressList = addressMapper.addressList(openId, addressId);
Log.info("参数:" + addressList);
if (!addressList.equals("") || addressList != null) {
rtnJson.put("errorNo", "0");
......@@ -79,7 +79,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
public JSONObject addressId(Long id,String appId) {
JSONObject rtnJson = new JSONObject();
try {
if (id.equals("")) {
if (id == null) {
rtnJson.put("errorNo", "1");
rtnJson.put("errorMsg", "id不能为空");
return rtnJson;
......@@ -89,11 +89,11 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
if (addressVOS!=null){
Log.info("参数:"+addressVOS);
rtnJson.put("errorNo","0");
rtnJson.put("errorMsg",addressVOS);
rtnJson.put("data",addressVOS);
}
} catch (Exception e) {
e.printStackTrace();
rtnJson.put("errorNO", "1");
rtnJson.put("errorNo", "1");
}
return rtnJson;
}
......
......@@ -37,8 +37,8 @@ public class MobileAddressController {
* @Param
**/
@RequestMapping(value = "/addressList", method = {RequestMethod.GET, RequestMethod.POST}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JSONObject addressList(String openId, String appId) {
return addressService.addressList(openId,appId);
public JSONObject addressList(String openId, String appId, Long addressId) {
return addressService.addressList(openId, appId, addressId);
}
/**
......
......@@ -191,7 +191,7 @@ public class MobileQybaseController {
}
}
String filePath = USER_IMAGES_DIR + "";
String filePath = USER_IMAGES_DIR;
String picPath = filePath + File.separator + picFileName;
//取后缀
......
package com.cftech.base.org.api;
import com.cftech.accounts.model.MpAccountsEntity;
import com.cftech.core.constants.MpApiConstants;
import com.cftech.core.constants.WxApiConstants;
import com.cftech.core.util.MpTokenUtil;
import com.cftech.core.util.QyTokenUtil;
import com.cftech.core.util.SystemConfig;
import lombok.extern.slf4j.Slf4j;
......@@ -25,6 +27,9 @@ public class QyMediaUtil {
private final QyTokenUtil qyTokenUtil;
@Autowired
private MpTokenUtil mpTokenUtil;
// 图片目录
public static final String USER_IMAGES_DIR = SystemConfig.p.getProperty("userfiles.imgdir");
......@@ -53,6 +58,79 @@ public class QyMediaUtil {
return res;
}
/**
* 下载媒体文件至磁盘(服务号)
*
* @param accountsId 微信账号
* @param moduleName 模块名称,可不填
* @param mediaId 媒体的Id
* @return 形成的文件名称
*/
public String downloadMpMediaToDisk(Long accountsId, String moduleName, String mediaId) {
String finalFileName = "";
MpAccountsEntity accountsEntity = mpTokenUtil.searchAccountsById(accountsId);
BufferedInputStream bis = null;
FileOutputStream fos = null;
HttpURLConnection conn = null;
String requestUrl = MpApiConstants.MEDIA_GET.replace("ACCESS_TOKEN", mpTokenUtil.getToken(accountsEntity))
.replace("MEDIA_ID", mediaId);
try {
URL url = new URL(requestUrl);
conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setRequestMethod("GET");
//String fileExt = getFileEndWitsh(conn.getHeaderField("Content-Type"));
String fileExt = ".jpg";
String fileName = getRundomName(moduleName);
finalFileName = fileName + fileExt;
String dir = USER_IMAGES_DIR;
File ff = new File(dir);
if (!ff.exists()) {
ff.mkdir();
}
String realPath = dir + File.separator + finalFileName;
bis = new BufferedInputStream(conn.getInputStream());
fos = new FileOutputStream(new File(realPath));
byte[] buf = new byte[8096];
int size = 0;
while ((size = bis.read(buf)) != -1) {
fos.write(buf, 0, size);
}
fos.close();
bis.close();
conn.disconnect();
} catch (IOException e) {
log.error("下载媒体文件失败:{}", e.getMessage());
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
log.error("下载媒体文件失败 IOException:{}", e.getMessage());
}
}
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
log.error("下载媒体文件失败 IOException:{}", e.getMessage());
}
}
if (conn != null) {
conn.disconnect();
}
}
return finalFileName;
}
/**
* 下载媒体文件至磁盘
*
......
......@@ -10,5 +10,7 @@ public class MpApiConstants {
/* JSAPI_TICKET */
public static final String JSAPI_TICKET_GET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi";
public static final String MEDIA_GET = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID";
}
......@@ -127,6 +127,7 @@ public class QyTokenUtil {
return token;
} catch (IOException e) {
e.printStackTrace();
log.error("获取token失败" + e.getMessage());
}
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment