Commit c29e05e6 by jscat

nyx javaapp/weapp: 更新

1. weapp前端, javaapp后端联调, 完成竞答答题及结果入库流程
parent 32cfc084
USE rockwell_key;
USE rockwell_key;
......@@ -19,20 +19,21 @@ USE rockwell_key;
DROP TABLE IF EXISTS tbl_match;
CREATE TABLE tbl_match (
`match_id` VARCHAR(100) COMMENT '竞答的id, uuid format, mid_001',
`activity_id` VARCHAR(100) COMMENT '活动的id, uuid format, mid_001',
`activity_id` VARCHAR(100) COMMENT '活动的id, uuid format, aid_001',
`user_id` VARCHAR(100) COMMENT '用户的id, uuid format, uid_001',
`match_status` VARCHAR(2) COMMENT '(可用|不可用): 01|00; 为什么00,因为所有RequestParam参数的defaultValue都设为0值, 会被认为是空或者null',
`match_point` double(10,2) COMMENT '得分: 4.5 or 5.0',
`match_result` VARCHAR(20) COMMENT '结果: 9/10',
`member_id` VARCHAR(100) COMMENT '商家的id, uuid format, mid_001',
`qrcode_url` VARCHAR(200) COMMENT 'qrcode的二维码url',
`create_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`update_datetime` DATETIME DEFAULT NULL,
PRIMARY KEY(`match_id`),
KEY `query_key` (`activity_id`, `user_id`, `match_status`))
KEY `query_key` (`activity_id`, `member_id`, `user_id`, `match_status`))
ENGINE=INNODB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT='竞答结果';
INSERT INTO `tbl_match`(`match_id`, `activity_id`, `user_id`, `match_status`, `match_point`, `match_result`, `qrcode_url`, `create_datetime`,`update_datetime`)
INSERT INTO `tbl_match`(`match_id`, `activity_id`, `user_id`, `match_status`, `match_point`, `match_result`, `member_id`, `qrcode_url`, `create_datetime`,`update_datetime`)
VALUES
('mid_001', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '00', 4.0, '4/5', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'),
('mid_002', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '01', 3.0, '3/5', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'),
('mid_003', 'aid_002', 'uid_088a957b-78e9-49cd-980b-ce8bc47b4e11', '01', 4.0, '8/10', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45');
\ No newline at end of file
('mid_001', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '00', 4.0, '4/5', 'mid_123', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'),
('mid_002', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '01', 3.0, '3/5', 'mid_123', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'),
('mid_003', 'aid_002', 'uid_088a957b-78e9-49cd-980b-ce8bc47b4e11', '01', 4.0, '8/10', 'mid_123', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45');
\ No newline at end of file
/*
/*
......@@ -67,25 +67,24 @@
-- 创建完毕 -> 发布 releaseActivity()
-- 我的活动 -> 发布 releaseActivity()
三. 商家活动参与流程
三. 商家活动参与流程
三. 商家活动参与流程 activity -> quiz-info -> matchTest -> quiz-result -> my-points
1. 竞答
--311 进入竞答, weapp activity.wxml
--312 点击进入竞答详情页面 weapp activity.wxml <navigator>
--311 done 进入竞答, weapp activity.wxml
--312 done 点击进入竞答详情页面 weapp activity.wxml <navigator>
--313 回到首页 weapp quiz-info.wxml bindtap="toHome"
--314 页面分享 weapp quiz-info.js options.from == 'button'
--315 右上角分享 weapp quiz-info.js onShareAppMessage()
--316 立即参与 weapp quiz-info.wxml bindtap="toGame"
--317 转到竞答页 weapp quiz-info.js wx.navigateTo(/matchTest)
--318 下一题 weapp matchTest.wxml bindtap="onTypeNext"
--319 完成测试 weapp matchTest.js doneDaily()
--316 done 立即参与 weapp quiz-info.wxml bindtap="toGame"
--317 done 转到竞答页 weapp quiz-info.js wx.navigateTo(/matchTest)
--318 done 下一题 weapp matchTest.wxml bindtap="onTypeNext"
--319 done 完成测试 weapp matchTest.js doneDaily()
--3110 转到结果页 weapp quiz-info.js wx.navigateTo(/quiz-result)
--3111 查看积分 weapp quiz-result.wxml bindtap="onCheckPoints"
--3111 查看积分 weapp quiz-result.wxml bindtap="onCheckPoints" to my-points.wxml
--3112 分享战绩 weapp quiz-result.wxml open-type="share"
--3113 返回首页 weapp quiz-result.wxml bindtap="toHome"
2. 活动
--321 进入活动, weapp activity.wxml
--321 done 进入活动, weapp activity.wxml
图片 note_image
标题 title
价格 unit_price
......@@ -94,7 +93,9 @@
where 1=1
and tag='活动'
--322 点击进入活动详情页面 weapp activity_info.wxml todo 新增 activity_info.wxml todo-1:1的image
--322 点击进入活动详情页面 weapp activity_info.wxml todo 新增 activity_info.wxml todo-1:1的image
tips: 需要通过activity_id重新获取数据, 因为unit_price/product_desc 这个阶段不知道
图片 note_image
价格 unit_price1/unit_price2
标题 title
......
// pages/activity/activity.js
// pages/activity/activity.js
......@@ -218,15 +218,20 @@ Page({
result["product_desc"] = res.data.data[i].productDesc
result["price"] = res.data.data[i].price
result["note_image"] = res.data.data[i].noteImage.split("::")
var url = "../activity/quiz-info/quiz-info?"
var url_quiz = "../activity/quiz-info/quiz-info?"
+"&activity_id="+result["activity_id"]
+"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确
+"&title="+result["title"]
+"&content="+result["content"]
+"&like="+result["num_like"]
+"&quiz="+result["quiz"]
+"&point="+result["point"]
+"&member_id="+result["member_id"]
+"&member_name="+result["member_name"]
+"&member_slogan="+result["member_slogan"]
result["url"] = url
var url_activity = "../activity/activity-info/quiz-info?"
+"&activity_id="+result["activity_id"]
result["url"] = result["tag"]=='竞答'? url_quiz : url_activity
list.push(result)
}
......
// pages/index/note-info/note-info.js
// pages/index/note-info/note-info.js
......@@ -6,6 +6,11 @@ Page({
*/
data: {
/* 用于判断是否已经登陆 */
nyxCode : "",
authStatus : "0",
userInfo : {},
windowHeight: "",
windowWidth: "",
contentHeight: "",
......@@ -28,14 +33,26 @@ Page({
contentHeight : windowHeight * 0.675,
})
//初始化数据
if (wx.getStorageSync('nyxCode')) {
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
})
}
var quiz = _this.__data__.quiz
if (Object.keys(quiz).length==0 && options.title != "")
{
quiz['activity_id'] = options.activity_id;
quiz['note_image'] = options.note_image.split("::");
quiz['title'] = options.title;
quiz['content'] = options.content.split("::");
quiz['like'] = options.like;
quiz['quiz'] = options.quiz;
quiz['point'] = options.point;
quiz['member_id'] = options.member_id;
quiz['member_name'] = options.member_name;
quiz['member_slogan'] = options.member_slogan;
quiz['writer_name'] = options.writer_name == "null" ? "匿名用户" : options.writer_name;
......@@ -146,8 +163,16 @@ Page({
//跳转到知识竞答页面
toGame: function (e) {
var _this = this;
var url = "/pages/key/matchTest/matchTest?"
+ "&activity_id=" + _this.__data__.quiz["activity_id"]
+ "&quiz=" + _this.__data__.quiz["quiz"]
+ "&point=" + _this.__data__.quiz["point"]
+ "&member_id=" + _this.__data__.quiz["member_id"]
+ "&member_name=" + _this.__data__.quiz["member_name"]
+ "&title=" + _this.__data__.quiz["title"]
wx.navigateTo({
url: "/pages/key/matchTest/matchTest"
url: url
});
},
......
// pages/index/note-info/note-info.js
// pages/index/quiz-result/quiz-result.js
// pages/index/note-info/note-info.js
// pages/index/quiz-result/quiz-result.js
var config=wx.getStorageSync("config");
var app = getApp();
var util = require('./../../../utils/util.js')
Page({
/**
* 页面的初始数据
*/
data: {
/* 用于判断是否已经登陆 */
nyxCode : "",
authStatus : "0",
userInfo : {}, // nickName, avartarUrl, gender, province, city, country
windowHeight: "",
windowWidth: "",
contentHeight: "",
scrollLeft: 0, //切换栏的滚动条位置
curIndex : 0,
notes: {},
//竞答结果: match_id, member_name, title, num_valid, num_total, points
matchInfo : {},
//当前时间
nowDate : "",
},
......@@ -20,15 +32,37 @@ Page({
*/
onLoad: function (options) {
var _this = this;
//初始化数据
if (wx.getStorageSync('nyxCode')) {
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
})
}
var matchInfo = _this.__data__.matchInfo
if (Object.keys(matchInfo).length==0 && options.match_id != "")
{
matchInfo['match_id'] = options.match_id;
matchInfo['member_name'] = options.member_name;
matchInfo['title'] = options.title;
matchInfo['num_valid'] = options.num_valid;
matchInfo['num_total'] = options.num_total;
matchInfo['points'] = options.points;
}
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
var windowWidth = wx.getSystemInfoSync().windowWidth;//获取设备高度,小程序自带的方法
this.setData({
windowHeight: windowHeight,
windowWidth: windowWidth,
contentHeight : windowHeight * 0.675,
matchInfo : matchInfo,
nowDate: util.formatTime(new Date())
})
wx.setNavigationBarTitle({
title: '活动结果',
})
......
<view class="page">
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
<view class="page">
<!-- Tab: 酒肆风云 + 头像 -->
......@@ -13,9 +15,9 @@
</view>
</view>
<view class="t3 justify align">
<view class="t3-left">2020年7月27日 星期一</view>
<view class="t3-left">{{tutil.formatDate_ymdw_today(nowDate)}}</view>
<view class="t3-right" bindtap="onClickPoints">
<view style="line-height:1; font-size:14px">张三丰</view>
<view style="line-height:1; font-size:14px">{{userInfo.nickName}}</view>
</view>
</view>
</view>
......@@ -26,10 +28,10 @@
<!-- 文字内容 -->
<view class="note">
<view class="note-title" style="font-weight: bold">
Renaissance Bar知识竞答
{{matchInfo.member_name}} {{matchInfo.title}}
</view>
<view class="note-content">
张三丰 10题答对9题 喜提4.5积分
{{userInfo.nickName}} {{matchInfo.num_total}}题答对{{matchInfo.num_valid}}题 喜提{{matchInfo.points}}积分
</view>
<view class="note-content">
战胜99%玩家
......@@ -68,19 +70,4 @@
</view>
<!-- end bottom-->
<!-- start bottom-->
<!-- refer to https://www.jb51.net/article/129438.htm -->
<!-- <view class="bottom_total">
<view class="bottom_line"></view>
<view class="weui-flex" style="height: 180rpx;">
<view class="weui-flex__item weui-flex justify align"><view class="placeholder">
<button class="button-brown" bindtap="toBuy" formType="submit">查看积分</button>
</view></view>
<view class="weui-flex__item weui-flex justify align"><view class="placeholder">
<button class="button-red" bindtap="toGame">分享战绩</button>
</view></view>
</view>
</view> -->
<!-- end bottom-->
</view>
// pages/key/matchTest/matchTest.js
// pages/key/matchTest/matchTest.js
......@@ -20,7 +20,6 @@ Page({
nyxCode: "",
authStatus: "",
userInfo: {},
matchSeason: "", // 学习赛季
matchType: "", // 学习类别
isStudyDone: false, //是否已经完成该项学习
......@@ -50,7 +49,12 @@ Page({
// questionName: "",
// choiceString: []
quizResult : {},
// 接受从quiz-info来的参数
quizParam : {}, // activity_id, member_id, quiz, point, member_name, title
// 从tbl_quiz来的参数
quizInfo : {}, // questionId, questionName, answer
// 最后生成的结果
quizResult : {}, // num_valid, num_total, points
/* 评论 */
bGetCommentOp : false,
......@@ -69,7 +73,6 @@ Page({
/* 模态框 */
showModal: false,
},
/**
......@@ -84,11 +87,23 @@ Page({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
matchSeason: wx.getStorageSync('matchSeason'),
matchType: "daily", // 学习类型
})
}
var quizParam = _this.__data__.quizParam
var quiz_string = ""
if (Object.keys(quizParam).length==0 && options.activity_id != "")
{
quizParam['activity_id'] = options.activity_id;
quizParam['quiz'] = options.quiz;
quizParam['point'] = options.point;
quizParam['member_id'] = options.member_id;
quizParam['member_name'] = options.member_name;
quizParam['title'] = options.title;
quiz_string = options.quiz;
}
//随机获取10条数据的id
/**
* 系统配置:主要用于置底页面设置 step2
......@@ -96,12 +111,20 @@ Page({
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
this.setData({
windowHeight: windowHeight,
quizParam : quizParam
})
/* end */
if (_this.__data__.item_list.length == 0)
{
_this.getRand();
if(quiz_string != "")
{
_this.getQuiz(quiz_string);
}
else
{
_this.getRand();
}
_this.setData({
isStudyDone: false, //每次进来从新操作
})
......@@ -187,7 +210,7 @@ Page({
let cuu = e.target.id;//获取index值
console.log(cuu);
var operateResult = "";
var answer = _this.__data__.quizResult.answer;
var answer = _this.__data__.quizInfo.answer;
var score = _this.__data__.score;
//拿到已经回答的题目数
var item_index_done = _this.__data__.item_index_done;
......@@ -235,6 +258,7 @@ Page({
//拿到下一个item_index
var current_index = _this.__data__.item_index;
//指向下一题, 获取数据
current_index = current_index + 1
/*
......@@ -260,10 +284,10 @@ Page({
//功能实现
//逻辑判断
//超过了10题,溢出了,直接进入doneDaily
if(current_index >= 1)
//超过了10题(或者指定数量的题目),溢出了,直接进入doneTest
if(current_index >= _this.__data__.item_list.length)
{
_this.doneDaily()
_this.doneTest()
}
else
{
......@@ -306,6 +330,20 @@ Page({
})
},
// 获取指定quiz_string数据
getQuiz : function (quiz_string) {
var _this = this;
var itemList = quiz_string.split("::")
_this.setData({
item_list: itemList,
item_index: 0 //初始化item_index
})
var wid = itemList[0]
_this.getData(wid)
},
// 获取真实数据
getData: function (questionId) {
......@@ -332,7 +370,7 @@ Page({
}
result["choiceString"] = list
_this.setData({
quizResult : result,
quizInfo : result,
questionId: questionId,
})
}
......@@ -340,35 +378,33 @@ Page({
})
},
// 如果完成了10道题
doneDaily: function (res) {
/*
如果完成了指定的题目
1. 结算成绩
2. 存入数据库 tbl_match
3. 跳转到 /quiz-result.wxml 页面
*/
doneTest: function (res) {
var _this = this
wx.navigateTo({
url: "/pages/activity/quiz-result/quiz-result"
})
//     this.setData({
//       showModal: true
//     })
// wx.showModal({
// title: '恭喜你完成本次活动',
// content: '获得'+_this.__data__.score + '积分,打败80%的玩家',
// showCancel: false, // 将cancel按钮disable掉
// confirmText: '谢谢老师',
// success(res) {
// if (res.confirm) {
// // 用户点击了确定属性的按钮,于是跳转到tabbar /pages/key/key
// // wx.navigateTo 和 wx.redirectto都无法跳转到tabbar
// _this.setData({
// isStudyDone: true,
// item_index : 9,
// })
// // 基于用户交互原则,不直接跳转到/pages/key/key页面, 让用户自主选择
// // wx.switchTab({
// // url: '/pages/key/key'
// // });
// }
// }
// })
// 1. 结算成绩
var quizResult = {}
var num_valid = _this.__data__.score
var num_total = _this.__data__.item_list.length
var points = num_valid / num_total
var scores = parseFloat(_this.__data__.quizParam["point"])
var match_point = parseFloat(points * scores).toFixed(1)
// var match_result = num_valid + "/" + num_total
// 2. 存入数据库 tbl_match, 并且拿到 match_id
_this.uploadMatch(match_point, num_valid, num_total);
// 3. 跳转到 /quiz-result.wxml 页面
// matchId
// 成绩 quizResult
// 信息 quizParam, member_name, title
// _this.toResult()
},
......@@ -562,7 +598,7 @@ Page({
onSubmitComment: function (e) {
var _this = this;
var objectId = _this.__data__.questionId //获取index值
var objectName = _this.__data__.quizResult.questionName //获取index值
var objectName = _this.__data__.quizInfo.questionName //获取index值
let content = e.detail.value.content;//获取评论内容
var useridFrom = _this.__data__.nyxCode;//获取userid
var useridTo = e.detail.value.useridTo;//获取reply id
......@@ -656,26 +692,21 @@ Page({
},
/*
更新daily的记录到tbl_match表
更新test的记录到tbl_match表
*/
uploadDaily: function(e){
uploadMatch(match_point, num_valid, num_total){
var _this = this;
var strUrl = config.match_add_item_url
var quizIndex = _this.data.item_index_done
var score = _this.data.score
config.debug == 1?console.log("===upload strUrl "+strUrl+"_quizIndex_"+quizIndex+"_socre_"+score):""
config.debug == 1?console.log("===uploadMatch strUrl "+strUrl+"_point_"+match_point):""
wx.request({
url: strUrl,
method: 'POST',
data: {
matchSeason: _this.data.matchSeason,
matchType: _this.data.matchType,
matchTeam: _this.data.nyxCode,
matchScore: _this.data.score,
teamType: "blue",
matchResult: _this.data.item_index_done==10 ? 1 : 0, //item_index永远指向下一题
quizIndex : _this.data.item_index_done, //已完成的quiz数目, 范围是1...10
rankScore: _this.data.score,
activityId: _this.__data__.quizParam["activity_id"],
memberId: _this.__data__.quizParam["member_id"],
userId: _this.data.nyxCode,
matchPoint: match_point,
matchResult: num_valid + "/" + num_total,
},
header: {
"Content-Type": "application/x-www-form-urlencoded",
......@@ -683,9 +714,13 @@ Page({
},
dataType: "json",
success: function (res) {
if (res.statusCode == 200) {
if ( res.data.resultCode == 200 ) {
//表示提交成功
console.log("成绩记录成功");
//得到matchId
var matchList = res.data.data;
var match_id = matchList.length >= 1 ? matchList[0].matchId : ""
_this.toResultPage(match_id, num_valid, num_total, match_point)
}
}
})
......@@ -717,6 +752,27 @@ Page({
})
},
//跳转到竞答结果页 quiz-result.wxml
toResultPage(match_id, num_valid, num_total, match_point) {
// matchId
// 成绩 quizResult
// 信息 quizParam, member_name, title
// toResult
var _this = this;
var url = "/pages/activity/quiz-result/quiz-result?"
+ "&match_id=" + match_id
+ "&member_name=" + _this.__data__.quizParam["member_name"]
+ "&title=" + _this.__data__.quizParam["title"]
+ "&num_total=" + num_total
+ "&num_valid=" + num_valid
+ "&points=" + match_point
wx.navigateTo({
url: url
})
},
})
\ No newline at end of file
<!--pages/key/matchTest/matchTest.wxml-->
<!--pages/key/matchTest/matchTest.wxml-->
......@@ -49,10 +49,10 @@
<view hidden="{{isStudyDone}}"> <!-- start of isStudyDone flag -->
<view class="page__hd">
<!-- 标题 -->
<view class="page__desc">{{quizResult.questionName}}</view>
<view class="page__desc">{{quizInfo.questionName}}</view>
</view>
<view class="page__bd " wx:for-items="{{quizResult.choiceString}}" >
<view class="page__bd " wx:for-items="{{quizInfo.choiceString}}" >
<button class="weui-btn button-sp-area {{current_item == index?'btn-selected':'btn-not-selected'}}" bind:tap="onClick" disabled="{{button_disabled==1?true:false}}" id="{{index}}">
<image src="{{operateResult}}" style="vertical-align:middle;width:60rpx;height:60rpx" hidden="{{hidden_type==1?true:(current_item == index?false:true)}}" />
{{item}}
......@@ -61,7 +61,7 @@
<view class="page__hd" hidden="{{button_disabled==0}}">
<!-- 优化: 直接显示正确答案 -->
<view class="page__desc">推荐答案: {{tutil.formatAnswer(quizResult.answer)}}</view>
<view class="page__desc">推荐答案: {{tutil.formatAnswer(quizInfo.answer)}}</view>
</view>
<!-- <text>\n</text> -->
<view class="weui-flex">
......
// pages/my/my.js
// pages/my/my.js
......@@ -14,7 +14,6 @@ Page({
nyxCode : "",
authStatus : "0",
userInfo : {},
matchSeason : "",
bGetUserInfo : false,
bUpdateUserData: false,
......@@ -32,7 +31,6 @@ Page({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
matchSeason: wx.getStorageSync('matchSeason'),
})
}
......@@ -42,7 +40,6 @@ Page({
log.info("my_onLoad_nyxCode", _this.data.nyxCode)
log.info("my_onLoad_authStatus", _this.data.authStatus)
log.info("my_onLoad_userInfo", _this.data.userInfo)
log.info("my_onLoad_matchSeason", _this.data.matchSeason)
},
......
var formatTime = function (date) {
var formatTime = function (date) {
......@@ -19,14 +19,33 @@ var formatDate_md = function (date) {
var formatDate_ymd = function (date) {
// 输入 2020-02-04 19:33:00
// 返回 02-04
// 返回 2020-02-04
var str = date.toString().substring(0, 10)
return str
}
var formatDate_ymdw_today = function (date) {
// 输入 2020-02-04 19:33:00
// 返回 2020年02月04日
var date = getDate(date);
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var week = getWeekByDate_today(date)
return year +"年" + month + "月" + day + "日" + " " + week
}
var getWeekByDate_today = function (date) {
//数日
var show_day = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
var date = getDate(date);
var day = date.getDay();
return show_day[day];
}
var formatNumber = function(n) {
n = n.toString()
console.log(n)
return n[1] ? n : '0' + n
}
......@@ -40,31 +59,28 @@ var formatAnswer = function (n) {
switch (n) {
case "1":
answer = "A"
console.log("input is 1")
break;
case "2":
answer = "B"
console.log("input is 2")
break;
case "3":
answer = "C"
console.log("input is 3")
break;
case "4":
answer = "D"
console.log("input is 4")
break;
case "5":
answer = "E"
break;
default:
console.log("input is n")
break;
}
return answer
}
module.exports = {
formatDate_ymd: formatDate_ymd,
formatDate_ymdw_today: formatDate_ymdw_today,
formatDate_md: formatDate_md,
formatTime: formatTime,
formatNumber: formatNumber,
......
package cn.com.fun.nyxkey.api.domain;
package cn.com.fun.nyxkey.api.domain;
......@@ -16,6 +16,7 @@ import java.util.Date;
public class Rockwell_keyT_match{
private String matchId; // 竞答的id uuid format
private String activityId; // 活动id uuid format
private String memberId; // 商家的id uuid format
private String userId; // 用户的id uuid format
private String matchStatus; // (可用|不可用): 01|00
......
package cn.com.fun.nyxkey.api.service;
package cn.com.fun.nyxkey.api.service;
......@@ -30,7 +30,7 @@ public interface Rockwell_keyService {
JSONResult Rockwell_keyServiceGetT_match_by_matchid(String matchId);
JSONResult Rockwell_keyServiceGetT_match_by_page(String memberId, String userId, String matchStatus);
void Rockwell_keyServiceAddT_matchList(List<Rockwell_keyT_match> listRockwell_keyT_match);
void Rockwell_keyServiceAddT_matchItem(String matchId, String memberId, String userId,
JSONResult Rockwell_keyServiceAddT_matchItem(String matchId, String activityId, String memberId, String userId,
Double matchPoint, String matchResult, String qrcodeUrl);
void Rockwell_keyServiceUpdateT_match_status(String matchId);
void Rockwell_keyServiceAddT_match_bonusItem(String matchId, String userId, String userName, Double bonusPoint);
......
package cn.com.fun.nyxkey.api.service.impl;
package cn.com.fun.nyxkey.api.service.impl;
......@@ -178,13 +178,14 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
rockwell_keyMapper.addT_matchList(rockwell_keyT_matchQuery);
}
public void Rockwell_keyServiceAddT_matchItem(String matchId, String memberId, String userId,
public JSONResult Rockwell_keyServiceAddT_matchItem(String matchId, String activityId, String memberId, String userId,
Double matchPoint, String matchResult, String qrcodeUrl)
{
LOGGER.debug("find Rockwell_keyServiceAddT_matchItem");
Rockwell_keyT_match rockwell_keyT_match = new Rockwell_keyT_match();
rockwell_keyT_match.setMatchId(matchId);
rockwell_keyT_match.setMatchStatus("01");
rockwell_keyT_match.setActivityId(activityId);
rockwell_keyT_match.setMemberId(memberId);
rockwell_keyT_match.setUserId(userId);
rockwell_keyT_match.setMatchPoint(matchPoint);
......@@ -193,6 +194,13 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
rockwell_keyT_match.setCreateDatetime(new Date());
rockwell_keyT_match.setUpdateDatetime(new Date());
rockwell_keyMapper.addT_matchItem(rockwell_keyT_match);
List<Rockwell_keyT_match> listRockwell_keyT_match = new ArrayList<Rockwell_keyT_match>();
listRockwell_keyT_match.add(rockwell_keyT_match);
int totalCount = listRockwell_keyT_match.size();
JSONResult jsonResult = new JSONResult(totalCount, listRockwell_keyT_match);
return jsonResult;
}
/*
......
package cn.com.fun.nyxkey.api.web.controller;
package cn.com.fun.nyxkey.api.web.controller;
......@@ -129,6 +129,7 @@ public class NyxApiController {
*/
@ApiOperation(value="为t_match添加match,对应tbl_match", notes="为t_match添加match,对应tbl_match")
@ApiImplicitParams({
@ApiImplicitParam(name = "activityId", value = "活动的id", required = true, dataType = "String"),
@ApiImplicitParam(name = "memberId", value = "商户的id", required = true, dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户的id", required = true, dataType = "String"),
@ApiImplicitParam(name = "matchPoint", value = "得分: 4.5 or 5.0", required = true, dataType = "String"),
......@@ -136,7 +137,8 @@ public class NyxApiController {
})
@RequestMapping(value = "/nyx/match/add/item", method = RequestMethod.POST)
@ResponseBody
public void RockwellAddMatchItem(
public JSONResult RockwellAddMatchItem(
@RequestParam(value = "activityId", required = false, defaultValue = "0") String activityId,
@RequestParam(value = "memberId", required = false, defaultValue = "0") String memberId,
@RequestParam(value = "userId", required = false, defaultValue = "0") String userId,
@RequestParam(value = "matchPoint", required = false, defaultValue = "0.0") Double matchPoint,
......@@ -146,7 +148,7 @@ public class NyxApiController {
String matchId = "mid_"+UUID.randomUUID().toString();
//生成qrcode, 上传oss,得到qrcode_url
String qrcodeUrl = ossService.Rockwell_ossServiceGetQrcodeUrl(matchId);
keyService.Rockwell_keyServiceAddT_matchItem(matchId, memberId, userId, matchPoint, matchResult, qrcodeUrl);
return keyService.Rockwell_keyServiceAddT_matchItem(matchId, activityId, memberId, userId, matchPoint, matchResult, qrcodeUrl);
}
// APi2 t_match接口 jscat 20200731
......
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
......@@ -119,10 +119,11 @@ limitations under the License.
<!-- match api1-2 新增一条 tbl_match 记录 update jscat 20200731 -->
<insert id="addT_matchItem" parameterType="cn.com.fun.nyxkey.api.domain.Rockwell_keyT_match">
insert into tbl_match(match_id, member_id, user_id, match_status, match_point, match_result, qrcode_url, create_datetime,update_datetime)
insert into tbl_match(match_id, activity_id, member_id, user_id, match_status, match_point, match_result, qrcode_url, create_datetime,update_datetime)
values
(
#{matchId},
#{activityId},
#{memberId},
#{userId},
#{matchStatus},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论