123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- package service
- import (
- "app.yhyue.com/moapp/jybase/date"
- "app.yhyue.com/moapp/jybase/go-xweb/log"
- "app.yhyue.com/moapp/jybase/mysql"
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
- "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/resource"
- "context"
- "database/sql"
- "fmt"
- )
- type AuthService struct {
- GoodsCode string
- GoodsSpecId int64
- BasesqlConn *mysql.Mysql
- }
- //认证信息保存
- func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) {
- //先判断用户是否存在
- user := b.BasesqlConn.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
- "user_id": in.UserId, "appid": in.Appid,
- }, "id", "")
- if user != nil {
- if in.OperationType == "add" {
- return false, "用户已验证"
- }
- } else {
- if in.OperationType == "update" {
- return false, "用户未认证,不可修改"
- }
- }
- if in.OperationType == "update" {
- //修改处理
- data := map[string]interface{}{
- "name": in.Name,
- "phone": in.Phone,
- "position": in.Position,
- "department": in.Department,
- "mail": in.Mail,
- "ent_name": in.EntName,
- "source": entity.MEDICALDOMAIN,
- }
- ok1 := b.BasesqlConn.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId, "appid": in.Appid, "source": entity.MEDICALDOMAIN}, data)
- if ok1 {
- return true, ""
- } else {
- log.Println(fmt.Sprintf("认证修改失败:入参:%v:%v,", in.UserId, data))
- return false, "修改失败"
- }
- } else {
- //新增处理
- data := map[string]interface{}{
- "name": in.Name,
- "phone": in.Phone,
- "position": in.Position,
- "department": in.Department,
- "mail": in.Mail,
- "ent_name": in.EntName,
- "user_id": in.UserId,
- "create_time": date.NowFormat(date.Date_Full_Layout)),
- "appid": in.Appid,
- "source": entity.MEDICALDOMAIN,
- }
- msg := ""
- ok := b.BasesqlConn.ExecTx("认证信息保存", func(tx *sql.Tx) bool {
- ok1 := b.BasesqlConn.InsertByTx(tx, entity.DOMAIN_CAPITAL_RETENTION, data)
- if ok1 <= 0 {
- log.Println(fmt.Sprintf("认证失败:参数:%v", data))
- msg = "认证信息保存失败"
- return false
- }
- //开通权益
- req := &resource.PowerReq{
- Appid: in.Appid,
- GoodsCode: b.GoodsCode,
- GoodsSpecId: b.GoodsSpecId,
- EntId: 0,
- UserId: in.UserId,
- BuyNum: 1,
- Type: int64(1),
- }
- resq, err := entity.ResourceLib.PowerHandle(context.Background(), req)
- if err != nil || resq.Status != 1 {
- log.Println("权益开通调用失败:", req, resq)
- msg = "权益开通调用失败"
- return false
- }
- return ok1 > 0
- })
- return ok, msg
- }
- }
- //认证信息查询
- func (b AuthService) UserAuthInfo(in *medical.CommonReq) *map[string]interface{} {
- //先判断用户是否存在
- user := b.BasesqlConn.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
- "user_id": in.UserId, "appid": in.Appid, "source": entity.MEDICALDOMAIN,
- }, "*", "")
- return user
- }
|